/* $Header: p_inlet.c,v 2.2 01/10/02 10:27:51 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME:                                                        */
/* ============                                                        */
/*                                                                     */
/* Author:                                                             */
/*                                                                     */
/* MODULE PURPOSE:                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>
#include <error.h>
#include <exception.h>
#include <err_handler.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <i_op.h>
#include <p_status.h>
#include <math.h>
#include <pcb_defs.h>
#include <ramps.h>         /* needed for status.h */
#include <zone_config.h>   /* needed for status.h */
#include <zone_status.h>   /* needed for status.h */
#include <status.h>     /* pull in run clock and state */
#include <list_mgmt.h>
#include <iomap.h>
#include <glp.h>
#include <keyboard.h>

/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/

#include "proto.h"
#include "p_tcomp.h"
#include "pneu_int.h"

/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/

#define OLD_MISER_MODE 0

#define INLET_VOLT_FILTER_RATE    8
#define INLET_PRES_FILTER_RATE    8
#define INLET_FLOW_FILTER_RATE    8
#define VI_FLOW_FILTER_RATE      120
#define VI_FLTR_MAX_CNT          160
#define INLET_PRES_DELAY         10
#define INLET_FLOW_DELAY         10
#define VI_FILTER_DELAY          960
#define VI_FILTER_RATE           80

#define SETPT_TEMP_DELAY          8
#define ACTUAL_TEMP_DELAY        18

/*****************************/
/*   STATIC VARIABLES        */
/*****************************/


/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

U_INT32 CalcSeptumPurgeFlow ( pINLET_STATUS status, U_INT16 Pi )

/**end_proto**/
{
     if ( Pi == 0 ) return 0;

     return status->Tcomp_Tables->Purge_Regulator.Parms[ (U_INT8) status->Config->Gas_Type ].Purge_Flow +
        SignedQuadWordMultiplyDivide(
            status->Tcomp_Tables->Purge_Regulator.Parms[ (U_INT8) status->Config->Gas_Type ].dFlow_dPres,
            Pi,
            DF_DP_SCALE);

}

/**begin_proto**/

#pragma SECTION PROG=rom3

/**end_proto**/

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckForMiserMode( pINLET_STATUS status )

/**end_proto**/
{

      /* flows may not be reduced during Pre_Run or */
      /* before the Miser time setting during a run */


      if ( ( status->Wkfile->Miser_Mode == OFF ) || ( GetVISplitPort(status) == CAPPED ) )
      {
          return FALSE;
      }

      /* test Pre_Run_Ready first because RUN_ACTIVE transition modifies Pre_Run_Ready *after* Run_State */
      if ( Pre_Run_Ready || (( Run_State == RUN_ACTIVE ) && ( Run_Clock <= status->Wkfile->Miser_Time )))
      {
           return FALSE;
      }
      else
      {
           if (  status->VI_Flow_Mode == FALSE  ) return TRUE;
           /* REVISIT: enter warning into glp log here !! (iff can have miser_time .le. vi_inj_time ) */
           return FALSE;
      }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:        N O T   U S E D !!!                                 */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
#if 0
/**begin_proto**/

void CheckForLowMiserFlow( void )

/**end_proto**/
{
    U_INT32 column_flow;
    U_INT32 septum_purge_flow;
    U_INT32 total_flow;
    pINLET_STATUS status;

           if (( status->Has_Column ) &&
               ( status->Wkfile->Miser_Flow < (column_flow + septum_purge_flow) ))
           {
               /*  MISER FLOW TO LOW  */
               status->Low_Miser_Flow = TRUE;
               total_flow = column_flow + septum_purge_flow;
           }
           else
           {
                status->Low_Miser_Flow = FALSE;
           }

    total_flow = total_flow + 0;  /* eliminate the warning */

}
#endif
/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckForInletPurge( pINLET_STATUS status )

/**end_proto**/
{
     if (status->Ready.FS_Auto_Zero ) return status->Inlet_Purge  ; /* final(!) fix for PVCS#75 & dupls */
                                                                    /* Now can stop run w/ vent closed  */

     switch ( status->Wkfile->Injection_Mode )
     {
        case DIRECT: return FALSE ;

        case SPLIT:
        case SPLIT_PULSED: return TRUE;

        default:

          if ( status->Wkfile->Injection_Mode == SOLVENT_VENT )
          {
               /* test Pre_Run_Ready first because RUN_ACTIVE transition modifies Pre_Run_Ready *after* Run_State */
               if (( Run_State == RUN_ACTIVE ) &&
                  (( Run_Clock >= status->Wkfile->Vent_Time ) && ( Run_Clock <= status->Wkfile->Purge_Time )))
               {
                    return FALSE;
               }
               else
               {
                    return TRUE;
               }
          }
          else
          {
               /* test Pre_Run_Ready first because RUN_ACTIVE transition modifies Pre_Run_Ready *after* Run_State */
               /* also test for special operating mode for Restek inlet liner - stay in forward-pressure mode at */
               /* all times if purge time is 999.99 minutes */
               if ( Pre_Run_Ready || ( status->Wkfile->Purge_Time == RetTimeToMilliSecs ( 999990 )) ||
                                     (( Run_State == RUN_ACTIVE ) && ( Run_Clock <= status->Wkfile->Purge_Time )))
               {
                    return FALSE;
               }
               else
               {
                    if (  status->VI_Flow_Mode == FALSE  ) return TRUE;
                    /* REVISIT: enter warning into glp log here !! (iff can have purge_time .le. vi_inj_time ) */
                    return FALSE;
               }
          }
     }
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckForVIFlowMode( pINLET_STATUS status )

/**end_proto**/
{

     if (status->Wkfile->VI_Inj_Time == 0 ) return FALSE ;
/*   if (status->Wkfile->Injection_Mode == SPLIT ) return FALSE;  redundant w.r.t. 1st line */
     if (status->Ready.Purge_Off== 1 ) return FALSE;

     if (( Run_State == PRE_RUN ) && ( status->VI_Flow_Mode == 1  )) return TRUE ;

     if (( Run_State == RUN_ACTIVE ) && ( Run_Clock <= status->Wkfile->VI_Inj_Time )) return TRUE ;

/*{
     --------------------------------------------------------------------------------------------
  |  Can simplify:
  |  If in pre-run, split vent already closed and so in PRES_ONLY mode.
  |  Further, VI can only be DIRECT,SPLIT,SPLITLESS, and SPLIT exits @ line 2 above, so HAVE to be
  |  either SPLITLESS or DIRECT if get here.
  |
  |  Hence, use line that follows this comment block .
     --------------------------------------------------------------------------------------------

     if ( Pre_Run_Ready )
     {
        if (status->Wkfile->Injection_Mode == DIRECT ) return status->Ready.Pres.State==IN_CONTROL_ ;
        if (status->Wkfile->Injection_Mode == SPLITLESS )
        {
           return ( ( status->Ready.Pres.State==IN_CONTROL_) && ( status->Ready.Flow.State==IN_CONTROL_) ) ;
        }
     };
}*/

/*{  if ( Pre_Run_Ready ) return status->Ready.Pres.State==IN_CONTROL_ ;  /- this is the simplification }*/

/*   Below is yet another scheme ; the goal is to run filter long enough before using it's output                       */

     /*    VI_FILTER_STABILIZATION_TIME  ; !!!!! REVIST !!!!! this is the FINAL form  */
     /*    the next line is for DEVELOPEMENT only !!!! REVISIT !!!           */

     if (status->Wkfile->VI_Avg_Cntr==VI_FILTER_DELAY )
                                                         /* to tally iterations of VI filter once PREP.and.READY==1     */
     {
         status->Wkfile->VI_Avg_Cntr = 0;
         return TRUE ;
     };

     return FALSE;

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckForSolventVent( pINLET_STATUS status )

/**end_proto**/
{

     if (status->Wkfile->Injection_Mode != SOLVENT_VENT )
     {
          return FALSE;
     }
     else
     {
          /* test Pre_Run_Ready first because RUN_ACTIVE transition modifies Pre_Run_Ready *after* Run_State */
          if ( Pre_Run_Ready || (( Run_State == RUN_ACTIVE ) && ( Run_Clock <= status->Wkfile->Vent_Time )))
          {
               return TRUE;
          }
          else
          {
               return FALSE;
          }
     }

}

/**begin_proto**/

BIT8 EmitSolventVentWarning( pINLET_STATUS status )

/**end_proto**/

  /*   In solvent_vent mode @ PRES=0 the inlet is in a 3-port  */
  /* FFBP (ForwardFlow_BackPres) mode. At low/zero pres with   */
  /* large flow the pres setpt may not be reached. This causes */
  /* the BP integral_error term to grow . As   vent mode ends  */
  /* and the analytes are boiled onto the column the 2-port FP */
  /* ( ForwardPres, NO flow ) control mode begins. At this     */
  /* point the (potentially) large integral_error term is      */
  /* saved to init the FFBP mode the next time it is used.     */
  /*   In this case the next time is when PurgeTime begins.    */
  /* If FFBP is used in solvent_vent @ low/zero pressure the   */
  /* large integral_error may case a large pressure glitch     */
  /* when it is installed as purge time begins.                */
  /*   To solve this we modify the normal FFBP mode by giving  */
  /* the pcb^2 pressure channel the "FFFF" command. pcb^2      */
  /* responds to FFFF by :                                     */
  /* 1. Saving the existing PID actuals & valve duty cyc.      */
  /* 2. Setting the proportional vent valve to max duty cyc.   */
  /* 3. Ignoring the pressure ctrl loop.                       */
  /* 68K also responds by keeping the solenoid valve open      */
  /* (as opposed to closing it as in a normal S/SL 3-port to   */
  /*  2-port FFBP->FP transition).                             */
  /* These things allow max flow at min column head pressure   */
  /* while NOT building a large integral_error term.           */
  /*                                                           */
  /*   Just prior to resuming FFBP mode pcb^2 gets the "FFFE"  */
  /* cmd which causes it to recall that states saved away in   */
  /* step "1." above and to resume that control regime.        */
  /* When FFBP does resume 68K opens the solenoid ( which was  */
  /* already open ) and normal FFBP behaviour resumes.         */
  /*                                                           */
  /* Note: 3-port == "vent is open"; i.e. one "in" and two     */
  /*                 "out"s                                    */
  /*       2-port == "vent is closed"; i.e. one "in" and       */
  /*                  one "out"                                */

{
   if (( Run_State == RUN_ACTIVE ) && ( Run_Clock+200  >= status->Wkfile->Vent_Time ))
   {
        return TRUE;
   }
   else
   {
        return FALSE;
   }

}


/**begin_proto**/

BIT8 EmitInletPurgeWarning( pINLET_STATUS status )

/**end_proto**/
{

  /* the pcb needs to know at least 20mSec in advance that the */
  /* inlet purge valve will open so it can begin to close the  */
  /* the proportional valve downstream of the solenoid valve.  */
  /* so our job here is to find a time as close as possible to */
  /* the opening of the solenoid valve so we can inform the    */
  /* pcb.  since we multiplex control between the inlets, dets,*/
  /* and auxes, our evaluation rate is 10Hz (50Hz/5) giving    */
  /* a period of 100mSec.  So emit a true if we are in a run,  */
  /* Purge OFF, and within 100mSec of Purge Time.              */


     if (( status->Wkfile->Injection_Mode == SPLITLESS ) || ( status->Wkfile->Injection_Mode == SPLITLESS_PULSED ))
     {
          if (( Run_State == RUN_ACTIVE ) &&                          /* in a real run */
              ( (Run_Clock + 200) >= status->Wkfile->Purge_Time ))    /* within 100mSec of purge time */
          {
               return TRUE;
          }
          else
          {
               return FALSE;
          }
     }
     else
     {
         return FALSE;
     }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckForPressurePulse( pINLET_STATUS status )

/**end_proto**/
{


      if ((status->Wkfile->Injection_Mode != SPLITLESS_PULSED ) && (status->Wkfile->Injection_Mode != SPLIT_PULSED ))
      {
          return FALSE;
      }
            /* we need to look for the pressure pulse */

      /* test Pre_Run_Ready first because RUN_ACTIVE transition modifies Pre_Run_Ready *after* Run_State */
      if ( Pre_Run_Ready || (( Run_State == RUN_ACTIVE ) && ( Run_Clock  <= status->Wkfile->Pulse_Time )))
      {
              return TRUE;
      }
      else
      {
              return FALSE;
      }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*   To compensate for variation in column exit pressure that would    */
/*   otherwise cause V_avg_column to vary with P_ambient, etc.  .      */
/*   Approach:                                                         */
/*   1/ Using col NTP pressure & model, find V_avg                     */
/*   2/ Adjust pressure setpoint to get real gauge pressure            */
/*      that gives same avg velocity.                                  */
/*                                                                     */
/*   For unknown column use NullColumnPressureCompensation             */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

U_INT16  ColumnPressureCompensation( pINLET_STATUS status, U_INT16 Pi, U_INT16 oven_temp )

/**end_proto**/
{

    /** Pi represents NTP values above this point, **/
    /** and corrected for true atmospheric below   **/

    if (( status->Has_Column ) && ( Pi != 0 ))
    {
              /*
              U_INT16 CorrectForAtmospheric ( U_INT16 NTP_Pi, SOURCE_CONNECTION source, U_INT32 *correct_ratio,
                                              U_INT16 oven_temp, BIT8 calc_new_reference, BIT8 over_ridden )
              */

         Pi = CorrectForAtmospheric( Pi,
                                     status->Position,
                                     &status->Setpt_Correct_Ratio,
                                     oven_temp,
                                     ( status->Ready.Start        ||
                                       status->Ready.Pulse_On     ||
                                       status->Ready.Pulse_Off    ||
                                       status->Ready.SVent_On     ||
                                       status->Ready.SVent_Off    ||
                                       status->Ready.Inlet_On     ||
                                       status->Ready.Setpt_Change ||
                                       status->Slam_Pres_Setpt  ),
                                     ( status->Pressure_Pulse     ||
                                       status->Solvent_Vent )
                                   );
    }
    else
    {
       status->Setpt_Correct_Ratio = ATMP_FLOW_CORRECT_SCALING;
    }

    return Pi;
}

static void NullColumnPressureCompensation ( pINLET_STATUS status )

{
      status->Setpt_Correct_Ratio = ATMP_FLOW_CORRECT_SCALING;
      status->Actual_Correct_Ratio = ATMP_FLOW_CORRECT_SCALING;
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

U_INT16 RangeCheckPres( pINLET_STATUS status, U_INT16 Pi )

/**end_proto**/
{
    U_INT16 p_limit;

     p_limit = status->P_Sensor_Range;

     if ( Pi > p_limit )
     {
         status->Ready.Pres.Capped = TRUE;
         return p_limit;
     }
     else
     {
         status->Ready.Pres.Capped = FALSE;
         status->Ready.Pres.Capped = status->Ready.Pres.Temp_Exceeds_CF_Max;
         return Pi;
     }

}

U_INT16 RangeCheckRealPres( pINLET_STATUS status, U_INT16 Pi )

{
    U_INT16 p_limit;

     p_limit = status->Real_PS_Range;

     if ( Pi > p_limit )
     {
         status->Ready.Pres.Capped = TRUE;
         return p_limit;
     }
     else
     {
         status->Ready.Pres.Capped |= FALSE;  /* don't allow this to overwrite caps from RangeCheckPres */
         return Pi;
     }

}


/**begin_proto**/

U_INT32 RangeCheckFlow( pINLET_STATUS status, U_INT32 flow )

/**end_proto**/
{
    U_INT32 f_limit;

     f_limit = GetInletMaxFlowIu ( status, status->IU_Scaling );

     if ( flow > f_limit )
     {
         status->Ready.Flow.Capped = TRUE;
         return f_limit;
     }
     else
     {
         status->Ready.Flow.Capped = FALSE;
         return flow;
     }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void ManualSplitSplitless( pINLET_STATUS status )

/**end_proto**/
{
     BIT8     state;

     if ( status->Wkfile->Injection_Mode != SPLIT )
     {
         status->Ready.Controlling_Purge = TRUE;
     }
     else
     {
         status->Ready.Controlling_Purge = FALSE;
     }

     state                  = CheckForInletPurge   ( status );
     status->Ready.Purge_On = ( status->Inlet_Purge ^ state ) && state;       /* true only when first turned on */
     status->Ready.Purge_Off= ( status->Inlet_Purge ^ state ) && ~state;      /* true only when first turned off */
     status->Inlet_Purge    = state;

     status->Ready.Pres.Controlled = FALSE;
     status->Ready.Flow.Controlled = FALSE;

     status->Ready.Pulse_On        = FALSE;
     status->Ready.Saver_On        = FALSE;
     status->Ready.Pulse_Off       = FALSE;
     status->Ready.Saver_Off       = FALSE;


     /* for inlet purge to be on,  the valve must be off */
     /* for inlet purge to be off, the valve must be on  */
/*----------begin changed by wangwei----------------------*/
/*
     if ( status->Inlet_Purge == FALSE )
     {
          if ( status->Position == FRNT_INLET )
          {
               INTERRUPTS_OFF
               Zones3_Image |= SPLIT_VLVA_ON;
               ZONES_OUT3 = Zones3_Image;
               INTERRUPTS_ON
          }
          else
          {
               INTERRUPTS_OFF
               Zones3_Image |= SPLIT_VLVB_ON;
               ZONES_OUT3 = Zones3_Image;
               INTERRUPTS_ON
          }
     }
     else
     {
          if ( status->Position == FRNT_INLET )
          {
               INTERRUPTS_OFF
               Zones3_Image &= SPLIT_VLVA_OFF;
               ZONES_OUT3 = Zones3_Image;
               INTERRUPTS_ON
          }
          else
          {
               INTERRUPTS_OFF
               Zones3_Image &= SPLIT_VLVB_OFF;
               ZONES_OUT3 = Zones3_Image;
               INTERRUPTS_ON
          }
     }
*/
/*-----------end change--------------------------*/


}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void DetermineInletPressure ( pINLET_STATUS status )

/**end_proto**/
{

    U_INT16  Pi;

       if ( status->Pressure_Pulse )
       {
           Pi = status->Wkfile->Pressure_Pulse_Pressure;
       }
       else
       {
           if ( status->Controlled_By_Column )
           {
               Pi = FindSourcePressureWithColumns ( status->Position, status->Dcm2_Per_IU, status->Setpt_Oven_Temp );
           }
           else
           {
               Pi = status->Wkfile->Inlet_Pressure;
           }
       }

       Pi = RangeCheckPres( status, Pi );

       /* this is the ntp value we will control to. */
       status->Inlet_Pressure_Setpt = Pi;


       /* use a two stage filter to emulate what the pres setpt-actual loop will do to the setpt */
       /* this delayed value will be passed to the columns and used anywhere pres setpt is to be */
       /* displayed                                                                              */

       if (( !status->Ready.Pulse_On ) && (!status->Ready.Pulse_Off) && (!status->Slam_Pres_Setpt))
       {
          Filter16Bits( &status->Intermediate_Pres,           Pi,                         INLET_PRES_FILTER_RATE );
          Filter16Bits( &status->Delayed_NTP_Inlet_Pres_Setpt, status->Intermediate_Pres, INLET_PRES_DELAY       );
       }
       else
       {
           /* we want the displayed setpt to jump to the pulse value when pulse is first enabled */
          status->Intermediate_Pres            = Pi;
          status->Delayed_NTP_Inlet_Pres_Setpt = Pi;
       }

       /* update the columns with this new delayed ntp pres setpt */

       if ( Inst_Config.Pneu.Column_1.Source == status->Position )
       {
             OverideColumnSetpt ( status->Delayed_NTP_Inlet_Pres_Setpt, &Inst_Status.Pneu.Column_1, status->Dcm2_Per_IU );
       }
       if ( Inst_Config.Pneu.Column_2.Source == status->Position )
       {
             OverideColumnSetpt ( status->Delayed_NTP_Inlet_Pres_Setpt, &Inst_Status.Pneu.Column_2, status->Dcm2_Per_IU );
       }


       /*** *** ***  NTP - REAL   break point  *** *** *** ***/

       Pi = ColumnPressureCompensation( status, Pi, status->Setpt_Oven_Temp );

       status->Compensated_Pressure = Pi;

       Pi = RangeCheckRealPres( status, Pi );

       Filter16Bits( &status->Filtered_Inlet_Pressure_Setpt, Pi, INLET_PRES_FILTER_RATE );

       status->Pres_Adc_Setpt = PresToVolts( status->Filtered_Inlet_Pressure_Setpt,
                                             &status->Tcomp_Tables->Pres_Sensor,
                                             status->Tcomp_Tables->Thermistor.Module_Temperature,
                                             status->Calib.P_Sensor_Offset,
                                             status->Calib.P_Sensor_Gain  );

       /* if we have a ss inlet in split mode, and the flow value is non-zero */
       /* then we must prevent the pres value (as seen by the dsp) from being */
       /* zero (which it interprets as off) to keep the inlet from charging   */
       /* up to line pressure.                                                */
       if ( ((status->Config->Type == SS) || (status->Config->Type == VOLATILES)) &&
            ( status->PCB_Inlet_Control_Mode == FWD_FLOW_BACK_PRES ) &&
            ( status->Filtered_Total_Inlet_Flow_Setpt != 0 )         &&
            ( status->Pres_Adc_Setpt == 0x0000 )                              )   status->Pres_Adc_Setpt = 0x0001;

       /* do to filtering on the actual (both bby the 331 and pcb2) there is a time delay.  */
       /* this filter is used to delay the setpt at the same rate as the actual is delayed. */
       /* readiness will compare the two delayed values.                                    */

       Filter16Bits( &status->Delayed_Inlet_Pressure_Setpt, status->Filtered_Inlet_Pressure_Setpt, INLET_PRES_DELAY );


}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void DetermineGerstelPtvPressure ( pINLET_STATUS status )

/**end_proto**/
{

    U_INT16  Pi;

       if ( status->Pressure_Pulse )
       {
           Pi = status->Wkfile->Pressure_Pulse_Pressure;
       }
       else if (status->Solvent_Vent )
       {
           Pi = status->Wkfile->Vent_Pressure;
       }
       else
       {
           if ( status->Controlled_By_Column )
           {
               Pi = FindSourcePressureWithColumns ( status->Position, status->Dcm2_Per_IU, status->Setpt_Oven_Temp );
           }
           else
           {
               Pi = status->Wkfile->Inlet_Pressure;
           }
       }

       Pi = RangeCheckPres( status, Pi );

       /* this is the ntp value we will control to. */
       status->Inlet_Pressure_Setpt = Pi;


       /* use a two stage filter to emulate what the pres setpt-actual loop will do to the setpt */
       /* this delayed value will be passed to the columns and used anywhere pres setpt is to be */
       /* displayed                                                                              */

       if ((!status->Ready.Pulse_On  ) &&
           (!status->Ready.Pulse_Off ) &&
           (!status->Ready.SVent_On  ) &&
           (!status->Ready.SVent_Off ) &&
           (!status->Slam_Pres_Setpt))
       {
          Filter16Bits( &status->Intermediate_Pres,           Pi,                         INLET_PRES_FILTER_RATE );
          Filter16Bits( &status->Delayed_NTP_Inlet_Pres_Setpt, status->Intermediate_Pres, INLET_PRES_DELAY       );
       }
       else
       {
           /* we want the displayed setpt to jump to the pulse value when pulse is first enabled */
          status->Intermediate_Pres            = Pi;
          status->Delayed_NTP_Inlet_Pres_Setpt = Pi;
       }

       /* update the columns with this new delayed ntp pres setpt */

       if ( Inst_Config.Pneu.Column_1.Source == status->Position )
       {
             OverideColumnSetpt ( status->Delayed_NTP_Inlet_Pres_Setpt, &Inst_Status.Pneu.Column_1, status->Dcm2_Per_IU );
       }
       if ( Inst_Config.Pneu.Column_2.Source == status->Position )
       {
             OverideColumnSetpt ( status->Delayed_NTP_Inlet_Pres_Setpt, &Inst_Status.Pneu.Column_2, status->Dcm2_Per_IU );
       }


       /*** *** ***  NTP - REAL   break point  *** *** *** ***/

       Pi = ColumnPressureCompensation( status, Pi, status->Setpt_Oven_Temp );

       status->Compensated_Pressure = Pi;

       Pi = RangeCheckRealPres( status, Pi );

       Filter16Bits( &status->Filtered_Inlet_Pressure_Setpt, Pi, INLET_PRES_FILTER_RATE );

       status->Pres_Adc_Setpt = PresToVolts( status->Filtered_Inlet_Pressure_Setpt,
                                             &status->Tcomp_Tables->Pres_Sensor,
                                             status->Tcomp_Tables->Thermistor.Module_Temperature,
                                             status->Calib.P_Sensor_Offset,
                                             status->Calib.P_Sensor_Gain  );

       /* if we have a ss inlet in split mode, and the flow value is non-zero */
       /* then we must prevent the pres value (as seen by the dsp) from being */
       /* zero (which it interprets as off) to keep the inlet from charging   */
       /* up to line pressure.                                                */
       if (
           /*
           ((status->Config->Type == SS ) || ( status->Config->Type == CIS3  ) || ( status->Config->Type == CIS4 )) &&
           */
           ( status->PCB_Inlet_Control_Mode == FWD_FLOW_BACK_PRES ) &&
           ( status->Filtered_Total_Inlet_Flow_Setpt != 0 )         &&
           ( status->Pres_Adc_Setpt == 0x0000 ))   status->Pres_Adc_Setpt = 0x0001;

       /* do to filtering on the actual (both bby the 331 and pcb2) there is a time delay.  */
       /* this filter is used to delay the setpt at the same rate as the actual is delayed. */
       /* readiness will compare the two delayed values.                                    */

       Filter16Bits( &status->Delayed_Inlet_Pressure_Setpt, status->Filtered_Inlet_Pressure_Setpt, INLET_PRES_DELAY );


}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

U_INT32 FindSSInletFlows ( pINLET_STATUS status )

/**end_proto**/
{

    BIT8    too_much_flow;
    U_INT32 max_flow;

    too_much_flow = FALSE;

    max_flow = 9999 * status->IU_Scaling;  /* displayable limit */
                                           /* This is ~ 8000 ml/min & is beyond any flow channels ability.  It is used */
                                           /*  to allow user to move from valid pneu state A to valid pneu state C     */
                                           /*  by way of keystrokes that take IQ through INVALID pneu state B.         */
                                           /* If the user tries to operate from an invalid pneu state such as B IQ     */
                                           /*  flags this condition with "not ready" exceptions"                       */
                                           /* A "valid pneu state" is a valid combination of inlet flow and pressure   */
                                           /*  setpoints that are all in bounds and available as keyboard entries.     */


    status->Septum = CalcSeptumPurgeFlow ( status, status->Compensated_Pressure );

    if (  status->Has_Column )
    {
         status->Ntp_Column = FindTotalColumnFlow( status->Position,
                                                   status->Inlet_Pressure_Setpt,
                                                   GetCurrentOvenTemp(),
                                                   status->IU_Scaling,
                                                   (max_flow - status->Septum),
                                                   &too_much_flow );
         if ( too_much_flow )
         {
              status->Ntp_Total  = max_flow;
              status->Ntp_Split  = 0;

              return status->Ntp_Total;
         }

         if ( status->Miser_Mode )
         {
#if OLD_MISER_MODE
             status->Ntp_Total  = status->Wkfile->Miser_Flow;
             if ( status->Ntp_Total > ( status->Ntp_Column + status->Septum )
             {
                 status->Ntp_Split  = status->Ntp_Total - status->Ntp_Column - status->Septum;
             }
             else
             {
                  status->Ntp_Split = 0;
                  status->Ntp_Total = status->Ntp_Column + status->Septum;
                  /* SetException( MISER_FLOW_LOW ); */
             }
#else
             status->Ntp_Split  = status->Wkfile->Miser_Flow;
             status->Ntp_Total  = status->Ntp_Split + status->Ntp_Column + status->Septum;
#endif
         }
         else
         {

              if (( status->Wkfile->Injection_Mode == SPLIT ) || ( status->Wkfile->Injection_Mode == SPLIT_PULSED ))
              {
                  status->Ntp_Split = BoundsCheckedQWMD( status->Ntp_Column,
                                                         status->Wkfile->Split_Ratio,
                                                         SPLIT_RATIO_INTERNAL_SCALE,
                                                         max_flow - status->Ntp_Column - status->Septum,
                                                         &too_much_flow );
                  if ( too_much_flow )
                  {
                       status->Ntp_Total  = max_flow;

                       return status->Ntp_Total;
                  }
              }
              else
              {
                   status->Ntp_Split = status->Wkfile->Purge_Flow;
              }

              status->Ntp_Total = status->Ntp_Column + status->Septum + status->Ntp_Split;
         }
    }
    else /* column is not defined */
    {

#if OLD_MISER_MODE
         if ( status->Miser_Mode )
         {
             status->Ntp_Total = status->Wkfile->Miser_Flow;
         }
         else
#endif
         {
             status->Ntp_Total = status->Wkfile->Total_Inlet_Flow;
         }
         if ( status->Inlet_Purge == TRUE  )
         {
            /* here we can't really know how much is split out and how much is */
            /* on the col, to have something in the display, divide it equally */
            status->Ntp_Split =
            status->Ntp_Column = ( status->Total - status->Septum ) / 2;
         }
         else
         {
            status->Ntp_Split = 0 ;
            status->Ntp_Column = status->Total - status->Septum ;
         }
    }

    return status->Ntp_Total;

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

U_INT32 FindGerstelInletFlows ( pINLET_STATUS status )

/**end_proto**/
{

    BIT8    too_much_flow;
    U_INT32 max_flow;

    too_much_flow = FALSE;

    max_flow = 9999 * status->IU_Scaling;  /* displayable limit */
                                           /* This is ~ 8000 ml/min & is beyond any flow channels ability.  It is used */
                                           /*  to allow user to move from valid pneu state A to valid pneu state C     */
                                           /*  by way of keystrokes that take IQ through INVALID pneu state B.         */
                                           /* If the user tries to operate from an invalid pneu state such as B IQ     */
                                           /*  flags this condition with "not ready" exceptions"                       */
                                           /* A "valid pneu state" is a valid combination of inlet flow and pressure   */
                                           /*  setpoints that are all in bounds and available as keyboard entries.     */

    status->Septum = CalcSeptumPurgeFlow ( status, status->Compensated_Pressure );

    if (  status->Has_Column )
    {
         /* here we can't really know how much is split out and how much is */
         /* on the col, to have something in the display, divide it equally */

         if ( status->Ready.InjWoPres )        /* if injecting without pressure */
         {
             status->Ntp_Total = status->Wkfile->Vent_Flow;
             status->Ntp_Split = status->Wkfile->Vent_Flow - status->Septum;
             status->Ntp_Column = 0;
         }
         else
         {

              status->Ntp_Column = FindTotalColumnFlow( status->Position,
                                                        status->Inlet_Pressure_Setpt,
                                                        GetCurrentOvenTemp(),
                                                        status->IU_Scaling,
                                                        (max_flow - status->Septum),
                                                        &too_much_flow );
              if ( too_much_flow )
              {
                   status->Ntp_Total  = max_flow;
                   status->Ntp_Split  = 0;

                   return status->Ntp_Total;
              }

              if ( status->Miser_Mode )
              {
                  status->Ntp_Split  = status->Wkfile->Miser_Flow;
                  status->Ntp_Total  = status->Ntp_Split + status->Ntp_Column + status->Septum;
              }
              else
              {

                   if (( status->Wkfile->Injection_Mode == SPLIT ) || ( status->Wkfile->Injection_Mode == SPLIT_PULSED ))
                   {
                       status->Ntp_Split = BoundsCheckedQWMD( status->Ntp_Column,
                                                              status->Wkfile->Split_Ratio,
                                                              SPLIT_RATIO_INTERNAL_SCALE,
                                                              max_flow - status->Ntp_Column - status->Septum,
                                                              &too_much_flow );
                       if ( too_much_flow )
                       {
                            status->Ntp_Total  = max_flow;

                            return status->Ntp_Total;
                       }
                   }
                   else if ( status->Solvent_Vent )
                   {
                        status->Ntp_Total = status->Wkfile->Vent_Flow;
                        if ( status->Ntp_Total < status->Septum )
                        {
                            status->Septum = status->Ntp_Total;
                            status->Ntp_Column = 0;
                            status->Ntp_Split  = 0;
                            return status->Ntp_Total;
                        }
                        else if ( status->Ntp_Total < (status->Septum + status->Ntp_Column) )
                        {
                            status->Ntp_Column = (status->Ntp_Total - status->Septum );
                            status->Ntp_Split  = 0;
                            return status->Ntp_Total;
                        }
                        else
                        {
                            status->Ntp_Split  = status->Ntp_Total - status->Ntp_Column - status->Septum;
                            return status->Ntp_Total;
                        }

                   }
                   else
                   {
                        status->Ntp_Split = status->Wkfile->Purge_Flow;
                   }

                   status->Ntp_Total = status->Ntp_Column + status->Septum + status->Ntp_Split;
              }
         }
    }
    else /* column is not defined */
    {
         /* here we can't really know how much is split out and how much is */
         /* on the col, to have something in the display, divide it equally */

         if ( status->Solvent_Vent )
         {
             status->Ntp_Total = status->Wkfile->Vent_Flow;
             status->Ntp_Split =
             status->Ntp_Column = ( status->Total - status->Septum ) / 2;
         }
         else
         {
             status->Ntp_Total = status->Wkfile->Total_Inlet_Flow;
             if ( status->Inlet_Purge == TRUE  )
             {
                /* here we can't really know how much is split out and how much is */
                /* on the col, to have something in the display, divide it equally */
                status->Ntp_Split =
                status->Ntp_Column = ( status->Total - status->Septum ) / 2;
             }
             else
             {
                status->Ntp_Split = 0 ;
                status->Ntp_Column = status->Total - status->Septum ;
             }

         }
    }

    return status->Ntp_Total;
}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

U_INT32 FindPPInletFlows ( pINLET_STATUS status )

/**end_proto**/
{

    U_INT32 total_column_flow;
    U_INT32 column_flow;

    BIT8    too_much_flow;
    U_INT32 max_flow;

    too_much_flow = FALSE;

    max_flow = 9999 * status->IU_Scaling;  /* displayable limit */
                                           /* This is ~ 8000 ml/min & is beyond any flow channels ability.  It is used */
                                           /*  to allow user to move from valid pneu state A to valid pneu state C     */
                                           /*  by way of keystrokes that take IQ through INVALID pneu state B.         */
                                           /* If the user tries to operate from an invalid pneu state such as B IQ     */
                                           /*  flags this condition with "not ready" exceptions"                       */
                                           /* A "valid pneu state" is a valid combination of inlet flow and pressure   */
                                           /*  setpoints that are all in bounds and available as keyboard entries.     */

    status->Ntp_Split = 0;

    if (  status->Has_Column )
    {
         status->Septum = CalcSeptumPurgeFlow ( status, status->Compensated_Pressure );

         status->Ntp_Column = FindTotalColumnFlow( status->Position,
                                                   status->Inlet_Pressure_Setpt,
                                                   GetCurrentOvenTemp(),
                                                   status->IU_Scaling,
                                                   (max_flow - status->Septum),
                                                   &too_much_flow );
         if ( too_much_flow )
         {
              status->Ntp_Total  = max_flow;

              return status->Ntp_Total;
         }


         status->Ntp_Total = status->Ntp_Column + status->Septum;
    }
    else /* column is not defined */
    {
        if ( status->Controlled_By_Column )
        {
           status->Septum = CalcSeptumPurgeFlow ( status, status->Filtered_Current_Pressure );

           total_column_flow = 0;
           if ( Inst_Config.Pneu.Column_1.Source == status->Position )
           {
                  column_flow = GetCol1F( status->Position,
                                          status->IU_Scaling,
                                          max_flow - status->Septum,
                                          &too_much_flow,
                                          status->Setpt_Oven_Temp );
                  OverideColumnFlowSetpt ( column_flow,
                                          &Inst_Status.Pneu.Column_1,
                                           status->IU_Scaling,
                                           INLET_FLOW_FILTER_RATE,
                                           INLET_FLOW_DELAY );
                  if ( too_much_flow )
                  {
                      status->Ntp_Total = max_flow;

                      return max_flow;
                  }
                  total_column_flow += column_flow;
           }

           if ( Inst_Config.Pneu.Column_2.Source == status->Position )
           {
                  column_flow = GetCol2F( status->Position,
                                          status->IU_Scaling,
                                          max_flow - status->Septum,
                                          &too_much_flow,
                                          status->Setpt_Oven_Temp );
                  OverideColumnFlowSetpt ( column_flow,
                                          &Inst_Status.Pneu.Column_2,
                                           status->IU_Scaling,
                                           INLET_FLOW_FILTER_RATE,
                                           INLET_FLOW_DELAY );

                  if ( ( too_much_flow )                                 ||
                       ( total_column_flow + column_flow < column_flow ) ||
                       ( total_column_flow + status->Septum > max_flow ) )
                  {
                      status->Ntp_Total = max_flow;

                      return max_flow;
                  }

                  total_column_flow += column_flow;
           }

           status->Ntp_Column =  total_column_flow;

           status->Ntp_Total = status->Ntp_Column + status->Septum;
        }
        else  /* no column connected to this inlet */
        {
            status->Septum = CalcSeptumPurgeFlow ( status, status->Filtered_Current_Pressure );

            status->Ntp_Total = status->Wkfile->Total_Inlet_Flow;
            status->Ntp_Column = status->Ntp_Total - status->Septum;
        }
    }

    return status->Ntp_Total;

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

U_INT32 FindVIInletFlows ( pINLET_STATUS status )

/**end_proto**/
{

    BIT8    too_much_flow;
    U_INT32 max_flow;

    too_much_flow = FALSE;

    max_flow = 9999 * status->IU_Scaling;  /* displayable limit */
                                           /* This is ~ 8000 ml/min & is beyond any flow channels ability.  It is used */
                                           /*  to allow user to move from valid pneu state A to valid pneu state C     */
                                           /*  by way of keystrokes that take IQ through INVALID pneu state B.         */
                                           /* If the user tries to operate from an invalid pneu state such as B IQ     */
                                           /*  flags this condition with "not ready" exceptions"                       */
                                           /* A "valid pneu state" is a valid combination of inlet flow and pressure   */
                                           /*  setpoints that are all in bounds and available as keyboard entries.     */


    if (  status->Has_Column )
    {
       status->Septum = CalcSeptumPurgeFlow ( status, status->Compensated_Pressure );
    }
    else /* column is not defined */
    {
       status->Septum = CalcSeptumPurgeFlow ( status, status->Filtered_Current_Pressure );
    };

    /*********************************************************************************************************/
    /* The below transient minimizaton code runs as follows:                                                 */
    /*  1/ Put the ntp value   of the present actual flow into "sum1" . Do not include any septum flow into  */
    /*     sum1.                                                                                             */
    /*     sum1 = NTP_Adjusted_Current_Flow - Current_Septum_Flow  (see proc CalcSSInletCurrentFlows )       */
    /*  2/ Now find the VI sampling setpt ( "VI_Ntp_Total_Flow") , defined to be:                            */
    /*     VI_Ntp_Total_Flow = sum1 + Septum                                                                 */
    /*                                                                                                       */
    /* The subt'n and addition of the septum flows gaurantee that the raw "Flow_Adc_Actual" reading that     */
    /*  generated NTP_Adjusted_Current_Flow used in "1" above will be recovered and sent to PCB2 as the      */
    /*  "Flow_Adc_Setpt" by way of procs AdjustTotalInletFlow and FlowToVolts .                              */
    /*                                                                                                       */
    /* The embodiment of the above needs filtering b/c VI in "2-port" mode ( i.e. split vent idle/blocked )  */
    /* is in FWD_PRES_NO_FLOW mode with PID's running in PCB^2 that have high diff. gain ( to support        */
    /* fused silica transfer line in main flow path ) . This puts more noise into flow and pressure loops    */
    /* than we have if std S/SL fwd_pres PIDs are used. This means the result of "2/" above must be filtered */
    /* before use as the setpt in the "VI flow only" control mode during sampling.                           */
    /*                                                                                                       */
    /* The result of this is that the ACTUAL flow voltage prior to sampling will be used as the flow setpt   */
    /*  voltage as sampling begins.  By doing this at the NTP_Adjusted_Current_Flow "level", we can retain   */
    /*  compensation for pressure variation that may occur during the sampling process ( i.e. till           */
    /*  Smplng_End clocks out ). This compensation would be lost if 'Adc_Actual was mapped into 'Adc_Setpt.  */
    /*                                                                                                       */
    /* This scheme will minimize the pneu glitch at sampling start BUT some glitch is likely at sampling     */
    /*  end. This can happen since the "actual" flow taken as the VI_Inj_Flow at start may not be exactly    */
    /*  the same as the flow that results from column flow setpt calculations that resume when sampling      */
    /*  ends.                                                                                                */
    /*                                                                                                       */
    /* The user can avoid the effects of a glitch at "end" by setting the Sampling_End setpt to a time       */
    /*  into the seperation when the analytes are well into the column and only clean carrier gas is         */
    /*  available to be drawn into the frit bypass. This is not the case if the end glitch was minimized,    */
    /*  as the resulting start glitch is much for problematic for the user to avoid.                         */
    /*                                                                                                       */
    /*********************************************************************************************************/

    /* --------------------------- begin transient minimization code --------------------------- */
    if ( status->VI_Flow_Mode == TRUE )
    {
      status->Ntp_Split = 0;

      if ( status->Ready.VI_Flow_On  == TRUE )
      {
        status->Wkfile->VI_Ntp_Total_Flow = status->Wkfile->VI_Ntp_Avg_Total_Flow    ;
      }


      return status->Ntp_Total = status->Wkfile->VI_Ntp_Total_Flow;

    }
    /* --------------------------- end transient minimization code  ---------------------------- */


    if (  status->Has_Column )
    {
         status->Ntp_Column = FindTotalColumnFlow( status->Position,
                                                   status->Inlet_Pressure_Setpt,
                                                   GetCurrentOvenTemp(),
                                                   status->IU_Scaling,
                                                   (max_flow - status->Septum),
                                                   &too_much_flow );
         if ( too_much_flow )
         {
              status->Ntp_Total  = max_flow;
              status->Ntp_Split  = 0;

              return status->Ntp_Total;
         }

         if ( status->Miser_Mode )
         {
             status->Ntp_Split  = status->Wkfile->Miser_Flow;
             status->Ntp_Total  = status->Ntp_Split + status->Ntp_Column + status->Septum;
         }
         else
         {

              status->Ntp_Split = 0;

              switch ( status->Wkfile->Injection_Mode )
              {

                 case SPLIT:
                  status->Ntp_Split = BoundsCheckedQWMD( status->Ntp_Column,
                                                         status->Wkfile->Split_Ratio,
                                                         SPLIT_RATIO_INTERNAL_SCALE,
                                                         max_flow - status->Ntp_Column - status->Septum,
                                                         &too_much_flow );
                  if ( too_much_flow )
                  {
                       status->Ntp_Total  = max_flow;
                       return status->Ntp_Total;
                  };
                  break;

                 case SPLITLESS:
                  if ( status->VI_Flow_Mode == FALSE ) status->Ntp_Split = status->Wkfile->Purge_Flow;
                  break;

                 /*
                 case DIRECT:
                 default:
                 */

              };

              status->Ntp_Total = status->Ntp_Column + status->Septum + status->Ntp_Split;
         }
    }
    else /* column is not defined */
    {
         status->Ntp_Total = status->Wkfile->Total_Inlet_Flow;

         if ( status->Wkfile->Injection_Mode == DIRECT  )
         {
            status->Ntp_Split = 0 ;
            status->Ntp_Column = status->Total - status->Septum ;
         }
         else /* here IFF undef_col AND SPLIT_or_SPLITLESS */
         {

            status->Ntp_Total = status->Wkfile->Total_Inlet_Flow;

            if ( status->Inlet_Purge == TRUE  )
            {
               /* here we can't really know how much is split out and how much is */
               /* on the col, to have something in the display, divide it equally */
               status->Ntp_Split =
               status->Ntp_Column = ( status->Total - status->Septum ) / 2;
            }
            else
            {
               status->Ntp_Split = 0 ;
               status->Ntp_Column = status->Total - status->Septum ;
            }


         }
    }

    return status->Ntp_Total;

}

U_INT32 AdjustTotalInletFlow( pINLET_STATUS status, U_INT32 total_inlet_flow )
{
     status->Column = AdjustNtpFlow( status->Ntp_Column, status->Setpt_Correct_Ratio );
     status->Split  = AdjustNtpFlow( status->Ntp_Split, status->Setpt_Correct_Ratio );
     status->Total = AdjustNtpFlow( status->Ntp_Total - status->Septum, status->Setpt_Correct_Ratio ) + status->Septum;

     if ( status->Septum < total_inlet_flow )
     {
         return AdjustNtpFlow( total_inlet_flow - status->Septum, status->Setpt_Correct_Ratio ) + status->Septum;
     }
     else
     {
         return total_inlet_flow;
     }


}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void DetermineInletFlows( pINLET_STATUS status )

/**end_proto**/
{

       U_INT32 total_flow;

       switch ( status->Config->Type )
       {
           case PP:
           case ACI:
           case SIMDIST:
                    total_flow = FindPPInletFlows( status );
                    break;

           case VOLATILES:
                    total_flow = FindVIInletFlows( status );
                    break;

           default:
                    total_flow = FindSSInletFlows( status );
       }

       status->Inlet_Flow_Setpt = total_flow;

       total_flow = RangeCheckFlow ( status, total_flow );

       total_flow = AdjustTotalInletFlow( status, total_flow );

       if ( status->Ready.VI_Flow_On  == FALSE )
       {
          Filter32Bits( &status->Filtered_Total_Inlet_Flow_Setpt, total_flow, INLET_FLOW_FILTER_RATE );
       }
       else
       {
          status->Filtered_Total_Inlet_Flow_Setpt  = total_flow ;  /* slam the flow @ start of sampling time */
       }


       if ( total_flow == 0 )
       {
           status->Flow_Adc_Setpt = 0;
       }
       else
       {
           status->Flow_Adc_Setpt = FlowToVolts( status->Filtered_Total_Inlet_Flow_Setpt,
                                                  &status->Tcomp_Tables->Flow_Sensor,
                                                  status->Tcomp_Tables->Thermistor.Module_Temperature,
                                                  status->Calib.F_Sensor_Offset,
                                                  status->Calib.F_Sensor_Gain );
       }


       /* do to filtering on the actual (both bby the 331 and pcb2) there is a time delay.  */
       /* this filter is used to delay the setpt at the same rate as the actual is delayed. */
       /* readiness will compare the two delayed values.                                    */

       Filter32Bits( &status->Delayed_Total_Flow_Setpt, status->Filtered_Total_Inlet_Flow_Setpt, INLET_FLOW_DELAY );


       /* now, all of the above flow code was real, but the display wants NTP values.  */
       /* so go back and generate delayed ntp flows for the display.                   */
       /* also, when Miser, Purge flows come available, we want to slam the value into */
       /* the filters so that we don't have to watch them charge up                    */

       if (( !status->Ready.Purge_On  ) &&
           ( !status->Ready.Saver_On  )  &&
           ( !status->Ready.Saver_Off ) &&
           ( !status->Ready.Pulse_On  ) &&
           ( !status->Ready.Pulse_Off ) &&
           ( !status->Ready.SVent_On  ) &&
           ( !status->Ready.SVent_Off ) &&
           ( !status->Ready.VI_Flow_On  ) &&
           ( !status->Ready.VI_Flow_Off ) &&
           ( !status->Slam_Flow_Setpt ))
       {
          Filter32Bits( &status->Intermediate_Flow_Setpt,      status->Ntp_Total,               INLET_FLOW_FILTER_RATE );
          Filter32Bits( &status->Delayed_NTP_Inlet_Flow_Setpt, status->Intermediate_Flow_Setpt, INLET_FLOW_DELAY );
       }
       else
       {
          status->Intermediate_Flow_Setpt      = status->Ntp_Total;
          status->Delayed_NTP_Inlet_Flow_Setpt = status->Intermediate_Flow_Setpt;
       }

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void DetermineGerstelPtvFlows( pINLET_STATUS status )

/**end_proto**/
{

       U_INT32 total_flow;

       total_flow = FindGerstelInletFlows( status );

       status->Inlet_Flow_Setpt = total_flow;

       total_flow = RangeCheckFlow ( status, total_flow );

       total_flow = AdjustTotalInletFlow( status, total_flow );

       Filter32Bits( &status->Filtered_Total_Inlet_Flow_Setpt, total_flow, INLET_FLOW_FILTER_RATE );



        if ( total_flow == 0 )
        {
            status->Flow_Adc_Setpt = 0;
        }
        else
        {
            status->Flow_Adc_Setpt = FlowToVolts( status->Filtered_Total_Inlet_Flow_Setpt,
                                                  &status->Tcomp_Tables->Flow_Sensor,
                                                  status->Tcomp_Tables->Thermistor.Module_Temperature,
                                                  status->Calib.F_Sensor_Offset,
                                                  status->Calib.F_Sensor_Gain );
        }


       /* do to filtering on the actual (both bby the 331 and pcb2) there is a time delay.  */
       /* this filter is used to delay the setpt at the same rate as the actual is delayed. */
       /* readiness will compare the two delayed values.                                    */

       Filter32Bits( &status->Delayed_Total_Flow_Setpt, status->Filtered_Total_Inlet_Flow_Setpt, INLET_FLOW_DELAY );


       /* now, all of the above flow code was real, but the display wants NTP values.  */
       /* so go back and generate delayed ntp flows for the display.                   */
       /* also, when Miser, Purge flows come available, we want to slam the value into */
       /* the filters so that we don't have to watch them charge up                    */

       if (( !status->Ready.Purge_On ) && ( !status->Ready.Saver_On )  && ( !status->Ready.Saver_Off ) &&
           ( !status->Ready.Pulse_On ) && ( !status->Ready.Pulse_Off ) && ( !status->Slam_Flow_Setpt ))
       {
          Filter32Bits( &status->Intermediate_Flow_Setpt,      status->Ntp_Total,               INLET_FLOW_FILTER_RATE );
          Filter32Bits( &status->Delayed_NTP_Inlet_Flow_Setpt, status->Intermediate_Flow_Setpt, INLET_FLOW_DELAY );
       }
       else
       {
          status->Intermediate_Flow_Setpt      = status->Ntp_Total;
          status->Delayed_NTP_Inlet_Flow_Setpt = status->Intermediate_Flow_Setpt;
       }

}


static void ClearOnOffVars( pINLET_STATUS      status )

{
       /* clear the vars that are momentary markers for ON or OFF events ... */

       status->Ready.Pulse_Off       = FALSE;
       status->Ready.Pulse_On        = FALSE;
       status->Ready.Purge_Off       = FALSE;
       status->Ready.Purge_On        = FALSE;
       status->Ready.SVent_Off       = FALSE;
       status->Ready.SVent_On        = FALSE;
       status->Ready.Saver_Off       = FALSE;
       status->Ready.Saver_On        = FALSE;
       status->Ready.VI_Flow_Off     = FALSE;
       status->Ready.VI_Flow_On      = FALSE;

}


static void ClearLevelVars( pINLET_STATUS      status )

{
       /* Level vars can NOT be cleared here if a given inlet driver needs their
           previous value to generate the ON or OFF pulsed bit vars */

           status->Inlet_Purge      = FALSE;
           status->Miser_Mode       = FALSE;
           status->Pressure_Pulse   = FALSE;
           status->Solvent_Vent     = FALSE;
           status->Ready.InjWoPres  = FALSE;
           status->VI_Flow_Mode     = FALSE;

}

/***********************************************************************/
/* FUNCTION: SplitSplitless                                            */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void SplitSplitless( pINLET_STATUS      status )

/**end_proto**/
{

    BIT8     state;

       ClearOnOffVars( status );
       /* ClearLevelVars( status ); */
           status->Solvent_Vent     = FALSE;
           status->Ready.InjWoPres  = FALSE;
           status->VI_Flow_Mode     = FALSE;

       if (( status->Wkfile->Injection_Mode == SPLITLESS ) || ( status->Wkfile->Injection_Mode == SPLITLESS_PULSED ))
       {
           status->Ready.Controlling_Purge = TRUE;
       }
       else
       {
           status->Ready.Controlling_Purge = FALSE;
       }

       /* check for inlet purge must be done first, */
       /* FindInletFlow is dependant on it's return */

       state                  = CheckForInletPurge   ( status );
       status->Ready.Purge_On = ( status->Inlet_Purge ^ state ) && state;       /* true only when first turned on */
       status->Ready.Purge_Off= ( status->Inlet_Purge ^ state ) && !state;      /* true only when first turned off */
       status->Inlet_Purge    = state;

       state                  = CheckForPressurePulse( status );
       status->Ready.Pulse_On = ( status->Pressure_Pulse ^ state ) && ( state); /* true only when pulse first turned on */
       status->Ready.Pulse_Off= ( status->Pressure_Pulse ^ state ) && (!state); /* true only when pulse first turned off*/
       status->Pressure_Pulse = state;

       state                  = CheckForMiserMode    ( status );
       status->Ready.Saver_On = ( status->Miser_Mode ^ state ) && ( state);     /* true only when saver first turned on */
       status->Ready.Saver_Off= ( status->Miser_Mode ^ state ) && (!state);     /* true only when saver first turned off*/
       status->Miser_Mode     = state;

       Filter16Bits( &status->Actual_Oven_Temp, status->Setpt_Oven_Temp, ACTUAL_TEMP_DELAY );
       status->Setpt_Oven_Temp = GetCurrentOvenTemp();

       if ( status->Shutdown )
       {
           status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;
           status->Inlet_Purge    = TRUE;
           return;
       }

       DetermineInletPressure ( status );

       status->Ready.Pres.Controlled = TRUE;


       if ( status->Inlet_Purge == FALSE )
       {
           /* truely splitless */

           status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;

           if ( EmitInletPurgeWarning( status ) == TRUE ) status->Flow_Adc_Setpt = 0xfffe;
           else                                           status->Flow_Adc_Setpt = 0xffff;

           status->Ready.Flow.Controlled = FALSE;
       }
       else
       {
           /* split, or splitless after purge time */

           DetermineInletFlows( status );

           status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;

           status->Ready.Flow.Controlled = TRUE;
       }

       status->Slam_Pres_Setpt = FALSE;   /* reset the request once honored */
       status->Slam_Flow_Setpt = FALSE;   /* reset the request once honored */

}

/***********************************************************************/
/* FUNCTION: Gerstel CIS3 or CIS4 inlet driver                         */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void GerstelPTV( pINLET_STATUS      status )

/**end_proto**/
{

    BIT8     state;

       ClearOnOffVars( status );
       /* ClearLevelVars( status ); */
           status->VI_Flow_Mode     = FALSE;

       if (( status->Wkfile->Injection_Mode == SPLITLESS        ) ||
           ( status->Wkfile->Injection_Mode == SPLITLESS_PULSED ) ||
           ( status->Wkfile->Injection_Mode == SOLVENT_VENT     ))
       {
           status->Ready.Controlling_Purge = TRUE;
       }
       else
       {
           status->Ready.Controlling_Purge = FALSE;
       }

       /* check for inlet purge must be done first, */
       /* FindInletFlow is dependant on it's return */

       state                  = CheckForInletPurge   ( status );
       status->Ready.Purge_On = ( status->Inlet_Purge ^ state ) && state;       /* true only when first turned on */
       status->Ready.Purge_Off= ( status->Inlet_Purge ^ state ) && !state;      /* true only when first turned off */
       status->Inlet_Purge    = state;

       state                  = CheckForPressurePulse( status );
       status->Ready.Pulse_On = ( status->Pressure_Pulse ^ state ) && ( state); /* true only when pulse first turned on */
       status->Ready.Pulse_Off= ( status->Pressure_Pulse ^ state ) && (!state); /* true only when pulse first turned off*/
       status->Pressure_Pulse = state;

       state                  = CheckForMiserMode    ( status );
       status->Ready.Saver_On = ( status->Miser_Mode ^ state ) && ( state);     /* true only when saver first turned on */
       status->Ready.Saver_Off= ( status->Miser_Mode ^ state ) && (!state);     /* true only when saver first turned off*/
       status->Miser_Mode     = state;

       state                  = CheckForSolventVent  ( status );
       status->Ready.SVent_On = ( status->Solvent_Vent ^ state ) && ( state);  /* true only when rinse first turned on */
       status->Ready.SVent_Off= ( status->Solvent_Vent ^ state ) && (!state);  /* true only when rinse first turned off*/
       status->Solvent_Vent   = state;

       status->Ready.InjWoPres= state && (status->Wkfile->Vent_Pressure == 0 )
                                      && ( status->Filtered_Total_Inlet_Flow_Setpt != 0 ) ;

       Filter16Bits( &status->Actual_Oven_Temp, status->Setpt_Oven_Temp, ACTUAL_TEMP_DELAY );
       status->Setpt_Oven_Temp = GetCurrentOvenTemp();

       if ( status->Shutdown )
       {
           status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;
           status->Inlet_Purge    = TRUE;
           return;
       }

       DetermineGerstelPtvPressure ( status );

       status->Ready.Pres.Controlled = TRUE;


       if ( status->Inlet_Purge == FALSE )
       {
           /* truely splitless */

           status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;

           if ( EmitInletPurgeWarning( status ) == TRUE ) status->Flow_Adc_Setpt = 0xfffe;
           else                                           status->Flow_Adc_Setpt = 0xffff;

           status->Ready.Flow.Controlled = FALSE;
       }
       else
       {
           /* split, or splitless after purge time */

           DetermineGerstelPtvFlows( status );

           status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;

           status->Ready.Flow.Controlled = TRUE;

           if (status->Ready.InjWoPres)
           {
              if ( EmitSolventVentWarning( status ) == TRUE ) status->Pres_Adc_Setpt = 0xfffe;
              else                                            status->Pres_Adc_Setpt = 0xffff;

           }

       }

       status->Slam_Pres_Setpt = FALSE;   /* reset the request once honored */
       status->Slam_Flow_Setpt = FALSE;   /* reset the request once honored */

}

/***********************************************************************/
/* FUNCTION: PTVInlet()                                                */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void PTVInlet( pINLET_STATUS status )

/**end_proto**/
{


   GerstelPTV( status );


}


/***********************************************************************/
/* FUNCTION: CoolOnColumn()                                            */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void CoolOnColumn   ( pINLET_STATUS status )

/**end_proto**/
{
       ClearOnOffVars( status );
       ClearLevelVars( status );

       status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;

       status->Ready.Pres.Controlled = TRUE;
       status->Ready.Flow.Controlled = FALSE;
       status->Ready.Controlling_Purge = FALSE;

       status->Flow_Adc_Setpt = 0;

       Filter16Bits( &status->Actual_Oven_Temp, status->Setpt_Oven_Temp, ACTUAL_TEMP_DELAY );
       status->Setpt_Oven_Temp = GetCurrentOvenTemp();

       if ( status->Shutdown )
       {
           status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;
           status->Inlet_Purge    = FALSE;
           return;
       }

       DetermineInletPressure( status );

       status->Slam_Pres_Setpt = FALSE;   /* reset the request once honored */
       status->Slam_Flow_Setpt = FALSE;   /* reset the request once honored */
}

/***********************************************************************/
/* FUNCTION: PurgedPacked()                                            */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void PurgedPacked   ( pINLET_STATUS status )

/**end_proto**/
{

       ClearOnOffVars( status );
       ClearLevelVars( status );

       if ( status->Shutdown )
       {
           /* leave mode where it was */
           status->Inlet_Purge    = FALSE;
           return;
       }

       Filter16Bits( &status->Actual_Oven_Temp, status->Setpt_Oven_Temp, ACTUAL_TEMP_DELAY );
       status->Setpt_Oven_Temp = GetCurrentOvenTemp();

       /* has columun indicates that all column parameters are known */
       /* so that column flow calculations can be performed */


       if ( status->Has_Column )   /* pressure controlled */
       {
           status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;

           status->Flow_Adc_Setpt = 0;

           status->Ready.Pres.Controlled = TRUE;
           status->Ready.Flow.Controlled = FALSE;
           status->Ready.Controlling_Purge = FALSE;

           DetermineInletPressure( status );

           /* show the flow breakdown for diagnostics */

           (void) FindPPInletFlows( status );
           (void) AdjustTotalInletFlow( status, 0 );  /* only to display real column flows in pneu_keys */
       }
       else
       {   /* flow controlled */

           status->PCB_Inlet_Control_Mode = FWD_FLOW_NO_PRES;
           status->Pres_Adc_Setpt = 0;

           status->Ready.Pres.Controlled = FALSE;
           status->Ready.Flow.Controlled = TRUE;
           status->Ready.Controlling_Purge = FALSE;

           NullColumnPressureCompensation ( status );

           DetermineInletFlows ( status );
       }

       status->Slam_Pres_Setpt = FALSE;   /* reset the request once honored */
       status->Slam_Flow_Setpt = FALSE;   /* reset the request once honored */
}

/***********************************************************************/
/* FUNCTION: Volatiles                                                 */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void Volatiles( pINLET_STATUS      status )

/**end_proto**/
{

    BIT8     state;
    U_INT32  fltr_input ;

       ClearOnOffVars( status );
       /* ClearLevelVars( status ); */
           status->Pressure_Pulse   = FALSE;
           status->Solvent_Vent     = FALSE;
           status->Ready.InjWoPres  = FALSE;

       if ( status->Wkfile->Injection_Mode == SPLITLESS )
       {
           status->Ready.Controlling_Purge = TRUE;
       }
       else
       {
           status->Ready.Controlling_Purge = FALSE;
       }

       /* check for inlet purge must be done first, */
       /* FindInletFlow is dependant on it's return */

       state                  = CheckForInletPurge   ( status );
       status->Ready.Purge_On = ( status->Inlet_Purge ^ state ) && state;       /* true only when first turned on */
       status->Ready.Purge_Off= ( status->Inlet_Purge ^ state ) && !state;      /* true only when first turned off */
       status->Inlet_Purge    = state;

       state                     = CheckForVIFlowMode( status );
       status->Ready.VI_Flow_On  = ( status->VI_Flow_Mode ^ state ) && ( state); /* true iff first turned on */
       status->Ready.VI_Flow_Off = ( status->VI_Flow_Mode ^ state ) && (!state); /* true iff first turned off*/
       status->VI_Flow_Mode      = state;


       state                  = CheckForMiserMode    ( status );
       status->Ready.Saver_On = ( status->Miser_Mode ^ state ) && ( state);     /* true only when saver first turned on */
       status->Ready.Saver_Off= ( status->Miser_Mode ^ state ) && (!state);     /* true only when saver first turned off*/
       status->Miser_Mode     = state;

       Filter16Bits( &status->Actual_Oven_Temp, status->Setpt_Oven_Temp, ACTUAL_TEMP_DELAY );
       status->Setpt_Oven_Temp = GetCurrentOvenTemp();

       if ( ( status->Shutdown ) && ( GetVISplitPort(status )==PLUMBED ))  /* revisit ... what if capped ?? */
       {
           status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;
           status->Inlet_Purge    = TRUE;
           return;
       }

       DetermineInletPressure ( status ); /* includes call to ColumnPressureCompensation */

       status->Ready.Pres.Controlled = TRUE;
       status->Ready.Flow.Controlled = FALSE;

       if ( status->VI_Flow_Mode == TRUE )
       {
           if (status->Ready.Purge_Off)
           {
           status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;
           status->Flow_Adc_Setpt = 0x0000 ;
           }
           else
           {
           /* copied from flow controlled  PP */

           status->PCB_Inlet_Control_Mode = FWD_FLOW_NO_PRES;
           status->Pres_Adc_Setpt = 0;

           status->Ready.Pres.Controlled = FALSE;
           status->Ready.Flow.Controlled = TRUE;
           status->Ready.Controlling_Purge = FALSE;

/*         NullColumnPressureCompensation ( status );  revisit ; why commented out ??  */
/*         NullColumnPressureCompensation ( status );  Typically call ColumnPressureCompensation for known column       */
/*         NullColumnPressureCompensation ( status );  Typically call NullColumnPressureCompensation for unknown column */
/*         NullColumnPressureCompensation ( status );  If peaks are moving thru the column in this mode then the comp   */
/*         NullColumnPressureCompensation ( status );  is needed to stabilize R.T.s                                     */
/*          But - here we are on flow_only mode anyway which is low % precision with cap columns, so this will          */
/*                dominate RT precision & reproducibility anyway, so just use NullColumnPressComp and be done with it   */

           NullColumnPressureCompensation ( status );

           DetermineInletFlows ( status );
           }
       }
       else
       {
            if ( status->Inlet_Purge == FALSE )
            {
                /* truely splitless */

                if ( Pre_Run_Ready &&  status->Ready.Pres.State==IN_CONTROL_ )
                {
                   status->Septum = CalcSeptumPurgeFlow ( status, status->Compensated_Pressure ); /* pres SETPT here */

                   fltr_input = status->NTP_Adjusted_Current_Flow - status->Current_Septum_Flow + status->Septum ;

                   if (status->Wkfile->VI_Avg_Cntr == 0)
                   {
                      status->Wkfile->VI_Ntp_Avg_Total_Flow = fltr_input ;
                   }
                   else
                   {
                      Filter32Bits( &status->Wkfile->VI_Ntp_Avg_Total_Flow                                     ,
                                    fltr_input                                                                 ,
                                    VI_FILTER_RATE ) ;
                   }
                   status->Wkfile->VI_Avg_Cntr ++;
                }
                else
                {
                   status->Wkfile->VI_Avg_Cntr = 0 ;

                };

                status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;

#if 0           /* REVISIT !! change to "0" to open vent in DIRECT !! */

                if (status->Wkfile->Injection_Mode != DIRECT  )
                {
                     if ( EmitInletPurgeWarning( status ) == TRUE )
                     { status->Flow_Adc_Setpt = 0xfffe; }
                     else
                     {status->Flow_Adc_Setpt = 0xffff;  } ;
                }
                else
                { status->Flow_Adc_Setpt = 0x0000 ; }  ;
#endif

#if 1           /* REVISIT !! change to "1" to open vent in DIRECT !! */

                if ( (status->Wkfile->Injection_Mode != DIRECT ) &&
                     ( EmitInletPurgeWarning( status ) == TRUE )     )
                {
                  status->Flow_Adc_Setpt = 0xfffe;  /* here IFF SPLITLESS.and.Have_Warning */
                }
                else
                {
                  status->Flow_Adc_Setpt = 0xffff;
                } ;
#endif

                status->Ready.Flow.Controlled = FALSE;
            }
            else
            {
                /* split, or splitless after purge time */
                if (status->Ready.VI_Flow_Off )
                {
                status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;
                status->Flow_Adc_Setpt = 0x0000 ;
                }
                else
                {
                DetermineInletFlows( status );

                status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;

                status->Ready.Flow.Controlled = TRUE;
                }
            }
       }

       status->Slam_Pres_Setpt = FALSE;   /* reset the request once honored */
       status->Slam_Flow_Setpt = FALSE;   /* reset the request once honored */

}

/***********************************************************************/
/* FUNCTION: JackInTheBox()                                            */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calculate the required values for total inlet flow and for */
/*          the inlet (guage) pressure.  These values are then to be   */
/*          delinearized and converted to sensor volts.                */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

/**begin_proto**/

void JackInTheBox   ( pINLET_STATUS status )

/**end_proto**/
{

    U_INT16  volts;

       ClearOnOffVars( status );
       ClearLevelVars( status );

       switch ( status->JackInTheBoxControlMode )
       {
           case 1:  /* controlled by pressure value */
                    status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;
                    Filter16Bits( &status->Filtered_Inlet_Pressure_Setpt,
                                   status->Inlet_Pressure_Setpt,
                                   INLET_PRES_FILTER_RATE );
                    status->Pres_Adc_Setpt = PresToVolts( status->Filtered_Inlet_Pressure_Setpt,
                                                          &status->Tcomp_Tables->Pres_Sensor,
                                                          status->Tcomp_Tables->Thermistor.Module_Temperature,
                                                          0, CALIB_GAIN_SCALING );
                    status->Flow_Adc_Setpt = 0;
                    status->Ready.Pres.Controlled = TRUE;
                    status->Ready.Flow.Controlled = FALSE;
                    break;

           case 2:  /* controlled by flow value     */
                    /* use back pres to enable nl-pids even though no pres loop is running */
                    status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;
                    Filter32Bits( &status->Filtered_Total_Inlet_Flow_Setpt,
                                   status->Inlet_Flow_Setpt,
                                   INLET_FLOW_FILTER_RATE);
                    status->Flow_Adc_Setpt = FlowToVolts( status->Filtered_Total_Inlet_Flow_Setpt,
                                                          &status->Tcomp_Tables->Flow_Sensor,
                                                          status->Tcomp_Tables->Thermistor.Module_Temperature,
                                                          0, CALIB_GAIN_SCALING );
                    status->Pres_Adc_Setpt = 0;
                    status->Ready.Pres.Controlled = FALSE;
                    status->Ready.Flow.Controlled = TRUE;
                    break;

           case 3:  /* controlled by pressure voltage */
                    status->PCB_Inlet_Control_Mode = FWD_PRES_NO_FLOW;
                    volts = AddAdcOffset(status->JackInTheBoxControlVolts);
                    Filter16Bits( &status->Pres_Adc_Setpt, volts, INLET_VOLT_FILTER_RATE );
                    status->Inlet_Pressure_Setpt = VoltsToPres( status->Pres_Adc_Setpt,
                                                          &status->Tcomp_Tables->Pres_Sensor,
                                                          status->Tcomp_Tables->Thermistor.Module_Temperature,
                                                          0, CALIB_GAIN_SCALING );
                    Filter16Bits( &status->Filtered_Inlet_Pressure_Setpt,
                                  status->Inlet_Pressure_Setpt,
                                  INLET_PRES_FILTER_RATE );
                    status->Flow_Adc_Setpt = 0;
                    status->Ready.Pres.Controlled = TRUE;
                    status->Ready.Flow.Controlled = FALSE;
                    break;

           case 4:  /* controlled by flow voltage   */
                    /* use back pres to enable nl-pids even though no pres loop is running */
                    status->PCB_Inlet_Control_Mode = FWD_FLOW_BACK_PRES;
                    volts = AddAdcOffset(status->JackInTheBoxControlVolts);
                    Filter16Bits( &status->Flow_Adc_Setpt, volts, INLET_VOLT_FILTER_RATE );
                    status->Inlet_Flow_Setpt = VoltsToFlow( status->Flow_Adc_Setpt,
                                                            &status->Tcomp_Tables->Flow_Sensor,
                                                            status->Tcomp_Tables->Thermistor.Module_Temperature,
                                                          0, CALIB_GAIN_SCALING );
                    Filter32Bits( &status->Filtered_Total_Inlet_Flow_Setpt,
                                  status->Inlet_Flow_Setpt,
                                  INLET_FLOW_FILTER_RATE );
                    status->Pres_Adc_Setpt = 0;
                    status->Ready.Pres.Controlled = FALSE;
                    status->Ready.Flow.Controlled = TRUE;
                    break;

           default: /* inlet is off */
                    status->Flow_Adc_Setpt = 0;
                    status->Pres_Adc_Setpt = 0;
                    status->Ready.Pres.Controlled = FALSE;
                    status->Ready.Flow.Controlled = FALSE;

       }


}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CalcInletCurrentPres( pINLET_STATUS status )

/**end_proto**/
{

    U_INT16 inlet_pres;

    inlet_pres = VoltsToPres ( status->Pres_Adc_Actual,
                              &status->Tcomp_Tables->Pres_Sensor,
                               status->Tcomp_Tables->Thermistor.Module_Temperature,
                               status->Calib.P_Sensor_Offset,
                               status->Calib.P_Sensor_Gain );

    Filter16Bits( &status->Filtered_Current_Pressure,   inlet_pres, INLET_PRES_FILTER_RATE );

    if ( status->Has_Column )
    {
       status->NTP_Adjusted_Current_Pressure = CorrectToNTP ( inlet_pres,
                                                              status->Position,
                                                              &status->Actual_Correct_Ratio,
                                                              status->Actual_Oven_Temp,
                                                              status->Setpt_Correct_Ratio );
    }
    else
    {
       status->NTP_Adjusted_Current_Pressure = inlet_pres;
       status->Actual_Correct_Ratio          = ATMP_FLOW_CORRECT_SCALING;   /* unity gain */
    }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CalcSSInletCurrentFlows( pINLET_STATUS status )

/**end_proto**/
{

    U_INT32 inlet_flow;
    U_INT32 purge_flow;
    U_INT32 column_flow;

    inlet_flow = VoltsToFlow ( status->Flow_Adc_Actual,
                              &status->Tcomp_Tables->Flow_Sensor,
                               status->Tcomp_Tables->Thermistor.Module_Temperature,
                               status->Calib.F_Sensor_Offset,
                               status->Calib.F_Sensor_Gain );


    Filter32Bits( &status->Real_Filtered_Flow,          inlet_flow, INLET_FLOW_FILTER_RATE );
    Filter32Bits( &status->Filtered_Current_Total_Flow, inlet_flow, INLET_FLOW_FILTER_RATE );

    purge_flow = CalcSeptumPurgeFlow ( status, status->Filtered_Current_Pressure );

    if ( inlet_flow < purge_flow )
    {
         status->Current_Septum_Flow = purge_flow = inlet_flow;
         status->NTP_Adjusted_Current_Flow = AdjustFlowToNTP( inlet_flow, status->Actual_Correct_Ratio );
    }
    else
    {
        status->Current_Septum_Flow = purge_flow;
        inlet_flow = AdjustFlowToNTP( inlet_flow - purge_flow, status->Actual_Correct_Ratio ) + purge_flow;
        status->NTP_Adjusted_Current_Flow =  inlet_flow;
    }

    if ( status->Controlled_By_Column )
    {
        if ( Inst_Config.Pneu.Column_1.Source == status->Position )
             CalcColumnActuals( &Inst_Status.Pneu.Column_1, status->Actual_Oven_Temp );

        if ( Inst_Config.Pneu.Column_2.Source == status->Position )
             CalcColumnActuals( &Inst_Status.Pneu.Column_2, status->Actual_Oven_Temp );

        column_flow = GetTotalColumnFlowActual( status->Position, status->IU_Scaling );

        status->Current_NTP_Column_Flow = column_flow;

        if ( column_flow < (inlet_flow - purge_flow) )
        {
            status->Current_NTP_Split_Flow = inlet_flow - purge_flow - column_flow;
        }
        else
        {
            status->Current_NTP_Column_Flow = inlet_flow - purge_flow;
            status->Current_NTP_Split_Flow = 0;
        }
    }
    else
    {
        if ( inlet_flow > status->Current_Septum_Flow )
        {
           status->Current_NTP_Split_Flow = status->Current_NTP_Column_Flow =
               ( inlet_flow - status->Current_Septum_Flow ) / 2;
        }
        else
        {
           status->Current_NTP_Split_Flow = status->Current_NTP_Column_Flow = 0;
        }
    }
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CalcCOCInletCurrentFlows( pINLET_STATUS status )

/**end_proto**/
{

    if ( status->Controlled_By_Column )
    {
        if ( Inst_Config.Pneu.Column_1.Source == status->Position )
             CalcColumnActuals( &Inst_Status.Pneu.Column_1, status->Actual_Oven_Temp );
        if ( Inst_Config.Pneu.Column_2.Source == status->Position )
             CalcColumnActuals( &Inst_Status.Pneu.Column_2, status->Actual_Oven_Temp );
    }
    else
    {
        status->Current_NTP_Split_Flow = 0;
        status->Current_NTP_Column_Flow = 0;
    }
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CalcPPInletCurrentFlows( pINLET_STATUS status )

/**end_proto**/
{

    U_INT32 inlet_flow;
    U_INT32 purge_flow;

    inlet_flow = VoltsToFlow ( status->Flow_Adc_Actual,
                              &status->Tcomp_Tables->Flow_Sensor,
                               status->Tcomp_Tables->Thermistor.Module_Temperature,
                               status->Calib.F_Sensor_Offset,
                               status->Calib.F_Sensor_Gain );


    Filter32Bits( &status->Real_Filtered_Flow,          inlet_flow, INLET_FLOW_FILTER_RATE );
    Filter32Bits( &status->Filtered_Current_Total_Flow, inlet_flow, INLET_FLOW_FILTER_RATE );

    purge_flow = CalcSeptumPurgeFlow ( status, status->Filtered_Current_Pressure ); /* ACTUAL pres used here */

    if ( inlet_flow < purge_flow )
    {
         status->Current_Septum_Flow = inlet_flow;
         status->NTP_Adjusted_Current_Flow = AdjustFlowToNTP( inlet_flow, status->Actual_Correct_Ratio );
    }
    else
    {
        status->Current_Septum_Flow = purge_flow;
        status->NTP_Adjusted_Current_Flow =
                      AdjustFlowToNTP( inlet_flow - purge_flow, status->Actual_Correct_Ratio ) + purge_flow;
    }

    if ( status->Controlled_By_Column )
    {
        if ( Inst_Config.Pneu.Column_1.Source == status->Position )
             CalcColumnActuals( &Inst_Status.Pneu.Column_1, status->Actual_Oven_Temp );
        if ( Inst_Config.Pneu.Column_2.Source == status->Position )
             CalcColumnActuals( &Inst_Status.Pneu.Column_2, status->Actual_Oven_Temp );
    }
    else
    {
        status->Current_NTP_Split_Flow = 0;
        status->Current_NTP_Column_Flow = ( inlet_flow - purge_flow );
    }
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CalcJackInTheBoxFP( pINLET_STATUS status )

/**end_proto**/
{


    U_INT32 inlet_flow;
    U_INT16 inlet_pres;
    U_INT32 real_flow;


    inlet_pres = VoltsToPres ( status->Pres_Adc_Actual,
                              &status->Tcomp_Tables->Pres_Sensor,
                               status->Tcomp_Tables->Thermistor.Module_Temperature,
                               status->Calib.P_Sensor_Offset,
                               status->Calib.P_Sensor_Gain );

    inlet_flow = VoltsToFlow ( status->Flow_Adc_Actual,
                              &status->Tcomp_Tables->Flow_Sensor,
                               status->Tcomp_Tables->Thermistor.Module_Temperature,
                               status->Calib.F_Sensor_Offset,
                               status->Calib.F_Sensor_Gain );


    real_flow = inlet_flow;

    Filter16Bits( &status->Filtered_Current_Pressure,   inlet_pres, INLET_PRES_FILTER_RATE );
    Filter32Bits( &status->Filtered_Current_Total_Flow, inlet_flow, INLET_FLOW_FILTER_RATE );
    Filter32Bits( &status->Real_Filtered_Flow,          real_flow,  INLET_FLOW_FILTER_RATE );

    status->NTP_Adjusted_Current_Pressure = status->Filtered_Current_Pressure;
    status->NTP_Adjusted_Current_Flow = status->Filtered_Current_Total_Flow;

}

/********************************************************************************************************************/
/*   Generic Readiness State Machine                                                                                */
/*                                          ____________________                                                    */
/*   ___________________________________[2]|   NOT_CONTROLING   |            (1)                                    */
/*  |controlling                           |         T          |/_____________________________{X}                  */
/*  |    *           ___________________[1]|____________________|\     (~controlling) * (~shutdown)                 */
/*  |~ignore        |                                                                                               */
/*  | (1,5)         |"splitless->split transition"                                                                  */
/*  |               |controlling * ignore                                                                           */
/*  |               |(1,3)                                                                                          */
/*  |               |     __________________________________________________________________________                */
/*  |               |    |                                           ignore (1,3)                   |               */
/*  |               |    |                                                                          |               */
/*  |               |    |                    ______________________________________________________|_______        */
/*  |               |    |                   | "equib timer timeout"                                |       |       */
/*  |               |    |                   |        _______________________________________       |       |       */
/*  |               |    |                   |       |                       "ready" (1,2)   |      |       |       */
/*  |               |    |                   V       V                                      [4]    [1]      |       */
/*  |               |    |                 _____________                               _________________    |       */
/*  |               |    |        _____[1]| IN_CONTROL_ |      "not ready"            | NOT_READY_DELAY |   |       */
/*  |               |    |       |        |      T      |[2]_________________________\|        1        |   |       */
/*  |               |    | ignore|        |_____________|     ~in_bounds (1)         /|_________________|   |       */
/*  |               |    |  (1,3)|           ^ ^       ^                                ^       [3]  [2]    |       */
/*  |               |    |       |           | |       |                                |        |    |     |       */
/*  |               |    |       |           | |       |                                |________|    |     |       */
/*  |               |    |       |           | |       |                              ~in_bounds      |     |       */
/*  |               |    |       |  "timeout"| |       |                                  (4)         |     |       */
/*  |               |    |       |      TC>TO| |       |                                              |     |       */
/*  |               |    |       |      (1,2)| |       |                                              |     |       */
/*  |               V    V       V           | |       |                                              |     |       */
/*  |              _____________________     | |       |                                              |     |       */
/*  |             | IGNORE_IF_NOT_READY |[2]-' |       |                                              |     |       */
/*  |             |          T          |      |       |                                              |     |       */
/*  |             |_____________________|      |       |                                              |     |       */
/*  |                     [1]        __________|       |                    "not ready timer timeout" |     |       */
/*  |                      |        |                  |                          ~in_bounds * TC>NRD |     |       */
/*  |           "not ready"|        |"ready"           |                                        (1,2) |     |       */
/*  |            ~in_bounds|        |TC>TO             |                                              |     |       */
/*  |                   (6)|        |   *              |                                              |     |       */
/*  |                      |        |in_bounds         |in_bounds                                     |     |       */
/*  |                      |        |(1,2)             |   *                                          |     |       */
/*  |                      |        |                  |ST>IRD                                        |     |       */
/*  |                      V       [1]                 |                                              |     |       */
/*  |            ______________________                |                                              |     |       */
/*  |           | IGNORING_NOT_READY   |[3]____________|                                              |     |       */
/*  |     ___[5]|          T           |                                                              |     |       */
/*  |    |      |______________________|        {X}                                                   |     |       */
/*  |    |        ^    [4]   ^    [2]            |                                                    |     |       */
/*  |    |________|     |    |     |             |Enter Pre-Run                                       |     |       */
/*  |     ~in_bounds    |    |     |_________    |(splitless, gas saver on)                           |     |       */
/*  |         (6)       |    |               |   |                                                    |     |       */
/*  |                   |____|               |   |  __________________________________________________|     |       */
/*  |               in_bounds (7)            |   | |                                                        |       */
/*  |                                        |   | |                                                        |       */
/*  |                              "timeout" |   | |                                                        |       */
/*  |                     ~in_bounds * TC>TO |   | |   ________"not ready"______________                    |       */
/*  |                                  (1,2) |   | |  |          (1,2)                  |                   |       */
/*  |                                        V   V V  V                                [2]                  |       */
/*  |                                      _________________                         ______________         |       */
/*  |                                     | NOT_IN_CONTROL_ |                       |  READY_DELAY |[1]_____|       */
/*  |____________________________________\|       F         |                       |      F       |     TC>=ET     */
/*                                       /|_________________|                       |______________|        *       */
/*                                            ^         |                               ^               in_bounds   */
/*              ~(shutdown + forced_not_ready)|         |_______"ready"_________________|                 (1,5)     */
/*                                       (1,2)|                                                                     */
/*                                            |                                                                     */
/*                                            |                                                                     */
/*                                         __________________                   (1)                                 */
/*                                        | FORCED_NOT_READY |/___________________________________{X}               */
/*                                        |        F         |\   controlling * force_not_ready                     */
/*                                        |__________________|                   +                                  */
/*                                                                           shutdown                               */
/*                                                                                                                  */
/*  Note: (1,2,3,4,5,6,7) as follows:                                                      TC = Tic_Counter         */
/*                                                                                         ET = equib_time          */
/*   1 =  Tic_Counter <- 0       5 =  Timeout <- equib_time       [n] = order in          NRD = Not_Ready_Delay     */
/*   2 =  Timeout <- 0           6 =  Secondary_Timer <- 0           which exits are       TO = Timeout             */
/*   3 =  Timeout <- timeout     7 =  ++ Secondary_Timer             are evaluated.        ST = Secondary Timer     */
/*   4 =  ++ Tic_Counter                                                                  IRD = Ignore_Ready_Delay  */
/*                                                                                                                  */
/********************************************************************************************************************/

/**begin_proto**/

void EvalPneuReady( pHERE_I_COME ready,
                            BIT8 force_not_ready,
                            BIT8 shutdown,
                            BIT8 in_bounds,
                            BIT8 controlling,
                            BIT8 ignore,
                         U_INT16 timeout,
                         U_INT16 equib_time
                  )

/**end_proto**/
{

     if ( shutdown )     /* this first so shutdown has precedence */
     {
          /* unconditional transition */
          ready->State          = FORCED_NOT_READY;
          ready->Tic_Counter    = 0;
     }
     else if ( ! controlling )  /* if off */
     {
          /* unconditional transition */
          ready->State          = NOT_CONTROLING;
          ready->Tic_Counter    = 0;
     }
     else if ( force_not_ready )
     {
          /* unconditional transition */
          ready->State          = FORCED_NOT_READY;
          ready->Tic_Counter    = 0;
     }
     else
     {
          switch ( ready->State )
          {
          case READY_DELAY:     if ( in_bounds )
                                {    /* time out equib timer */
                                     if ( ++(ready->Tic_Counter) >= equib_time )
                                     {
                                           ready->State              = IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = equib_time;  /* allow for updates */
                                     }
                                }
                                else
                                {
                                           ready->State              = NOT_IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                }

                                break;

          case NOT_READY_DELAY: if ( ignore )
                                {
                                           ready->State              = IGNORE_IF_NOT_READY;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = timeout;
                                }
                                else if ( !in_bounds )
                                {    /* time out not ready timer */
                                     if ( ++(ready->Tic_Counter) >= ready->Not_Ready_Delay )
                                     {
                                           ready->State              = NOT_IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                     }
                                }
                                else
                                {
                                           ready->State              = IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                }
                                break;

          case IN_CONTROL_:     if ( ignore )
                                {
                                    /* used to ignore real world ignores like injection solvent pulses,
                                       splitless->split transitions, gas saver startup, etc            */
                                           ready->State              = IGNORE_IF_NOT_READY;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = timeout;
                                }
                                else if ( !in_bounds )
                                {
                                           ready->State              = NOT_READY_DELAY;
                                           ready->Tic_Counter        = 0;
                                }
                                break;

          case FORCED_NOT_READY: /* to enter the switch, force has been removed, go to not in control */
                                           ready->State              = NOT_IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                break;

          case NOT_IN_CONTROL_: if ( in_bounds )
                                {
                                           ready->State              = READY_DELAY;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = equib_time;
                                }
                                break;

          case NOT_CONTROLING:  if (( controlling ) && ( ignore ))   /* splitless/split tranition */
                                {
                                           ready->State              = IGNORE_IF_NOT_READY;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = timeout;
                                }
                                else
                                {
                                           ready->State              = NOT_IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = equib_time;
                                }
                                break;

          case IGNORE_IF_NOT_READY: if ( !in_bounds )
                                {
                                    /* solvent pulses at injection time, pressure
                                       bleed down from pulses, flows dropped to
                                       in response to pressure spikes need to be
                                       filererd out, this will allow us to look
                                       for one of these not ready events             */

                                           ready->State              = IGNORING_NOT_READY;
                                           ready->Secondary_Timer    = 0;
                                }
                                else if ( ++(ready->Tic_Counter) >= ready->Timeout )
                                {
                                    /* never saw one within the timeout */

                                           ready->State              = IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                }
                                break;

          case IGNORING_NOT_READY:   /* check to see if the ignore timer expired */

                                if ( ++(ready->Tic_Counter) >= ready->Timeout )
                                {
                                    if ( in_bounds )
                                    {
                                           ready->State              = IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                    }
                                    else
                                    {
                                    if (ready->Timeout != 0xffff )
                                       {
                                           ready->State              = NOT_IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                       }
                                    }
                                }
                                else if ( in_bounds ) /* still within the ignore timer */
                                {
                                    /* require 1/2 second of continuous in_bounds before */
                                    /* declaring  ready and skipping out of the ignore   */
                                    /* 1/2 Sec = 5 ticks * 100mSec/tick                  */

                                    if ( ++(ready->Secondary_Timer) > IGNORE_READY_DELAY )
                                    {
                                           ready->State              = IN_CONTROL_;
                                           ready->Tic_Counter        = 0;
                                           ready->Timeout            = 0;
                                    }
                                }
                                else   /* must be out of bounds */
                                {
                                       ready->Secondary_Timer = 0;
                                }
                                break;

          }
     }


     switch ( ready->State )
     {
          case IN_CONTROL_:
          case NOT_CONTROLING:
          case NOT_READY_DELAY:
          case IGNORING_NOT_READY:
          case IGNORE_IF_NOT_READY: ready->Reported_Ready = TRUE;
                                    break;
          case READY_DELAY:
          case FORCED_NOT_READY:
          case NOT_IN_CONTROL_:     ready->Reported_Ready = FALSE;
                                    break;
     }


}

/**begin_proto**/

U_INT16 GetReadyTimeout   ( pINLET_STATUS status )

/**end_proto**/
{
      if (status -> Solvent_Vent) return  0xffff;
      return   (status->Ready.Start ? START_TIMEOUT : EVENT_TIMEOUT) / READY_EVAL_PERIOD  ;

}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckInletPresReadiness( pINLET_STATUS status )

/**end_proto**/
{

    status->Ready.Pres.Setpt  = status->Delayed_Inlet_Pressure_Setpt;
    status->Ready.Pres.Actual = status->Filtered_Current_Pressure;

    status->Ready.Pres.Difference = ( status->Ready.Pres.Actual - status->Ready.Pres.Setpt );

    switch ( status->Dcm2_Per_IU )
    {
    case  80: status->Ready.Pres.Bound =  (  3447 /  80 );  /* .05 PSI = 3447.378 Dynes/cm*cm */
              break;
    case 160: status->Ready.Pres.Bound =  (  6894 / 160 );  /* .1  PSI = 6894.757 Dynes/cm*cm */
              break;
    case 320: status->Ready.Pres.Bound =  ( 34473 / 320 );  /* .5  PSI = 34473.85 Dynes/cm*cm */
              break;
              /* default case to keep lint happy */
    default:  status->Ready.Pres.Bound =  (  6894 / 160 );  /* .1  PSI = 6894.757 Dynes/cm*cm */
    }

    status->Ready.Pres.In_Bounds = (status->Ready.Pres.Difference < 0) ?
                                    status->Ready.Pres.Difference > -status->Ready.Pres.Bound :
                                    status->Ready.Pres.Difference <  status->Ready.Pres.Bound ;

    EvalPneuReady(
                   &status->Ready.Pres,

                   /* BIT8 force_not_ready */
                   ( CountInletChangeRequests( status ) != 0 ) ||  /* forced not ready */
                   status->Ready.FS_Auto_Zero                  ||   /* performing a post run auto zero */
                   status->Ready.Pulse_On                      ||
                   status->Ready.Inlet_On                      ||
                   status->Ready.Setpt_Change                  ||
                   status->Ready.Pres.Capped                   ||
                   /* status->Ready.SVent_On                   ||  */
                   status->Ready.Pres.Temp_Exceeds_CF_Max      ||
                   (
                     (status->Ready.Pulse_Off   ||
                      status->Ready.Purge_On    ||
                      status->Ready.Purge_Off
                     )
                     &&
                     Run_State != RUN_ACTIVE
                   ),

                   /* BIT8 shutdown        */
                   status->Shutdown,

                   /* BIT8 in_bounds       */
                   status->Ready.Pres.In_Bounds,

                   /* BIT8 controlling     */
                   /* status->Ready.Pres.Controlled && (status->Wkfile->On_Off == ON), */   /* does ready matter */
                   status->Ready.Pres.Controlled && (status->Wkfile->On_Off == ON)
                                                 && (!status->Ready.InjWoPres),         /* does ready matter */

                   /* BIT8 ignore          */
                   status->Ready.InjWoPres ||
                   status->Ready.Start             ||   /* ignore not ready events */
                   status->Ready.VI_Flow_Off       ||
                   status->Ready.Pulse_Off         ||
                   /*
                   status->Ready.SVent_Off         ||
                   */
                   status->Ready.Purge_On          ||
                   status->Ready.Saver_On          ||
                   ( Run_State == RUN_ACTIVE ) && status->Ready.SVent_Off ,

                   /* U_INT16 timeout      */
                   /*
                   (status->Ready.Start ? START_TIMEOUT : EVENT_TIMEOUT) / READY_EVAL_PERIOD,
                   */
                   GetReadyTimeout(status),

                   /* BIT8 equib_time      */
                   status->Wkfile->Pres_Equib_Time / READY_EVAL_PERIOD
                 );


    return status->Ready.Pres.Reported_Ready == FALSE;
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 CheckInletFlowReadiness( pINLET_STATUS status )

/**end_proto**/
{

    status->Ready.Flow.Setpt  = status->Delayed_Total_Flow_Setpt;
    status->Ready.Flow.Actual = status->Filtered_Current_Total_Flow;

    status->Ready.Flow.Difference = ( status->Ready.Flow.Actual - status->Ready.Flow.Setpt );

    status->Ready.Flow.Bound =  status->IU_Scaling;  /* 1 mL/min */

    status->Ready.Flow.In_Bounds = (status->Ready.Flow.Difference < 0) ?
                                    status->Ready.Flow.Difference > -status->Ready.Flow.Bound :
                                    status->Ready.Flow.Difference <  status->Ready.Flow.Bound ;

    EvalPneuReady( &status->Ready.Flow,

                   ( CountInletChangeRequests( status ) != 0 ) ||   /* forced not ready conditions */
                   status->Ready.FS_Auto_Zero    ||   /* performing a post run auto zero */
                   status->Ready.Pulse_On        ||
                   status->Ready.Inlet_On        ||
                   status->Ready.Saver_Off       ||
                   status->Ready.Setpt_Change    ||
                   status->Ready.Flow.Capped     ||
                   status->Ready.Purge_Off       ||
                   status->Ready.SVent_On        ||
/*                 ( (status->Wkfile->VI_Inj_Time != 0 ) &&
                      Run_State == RUN_IDLE )    ||                   */
                   ((status->Ready.Pulse_Off  ||
                     status->Ready.Saver_On   ||
                     status->Ready.SVent_On   ||
                     status->Ready.Purge_On           ) && Run_State != RUN_ACTIVE ),

                   status->Shutdown,
                   status->Ready.Flow.In_Bounds,
                   status->Ready.Flow.Controlled && ( status->Wkfile->On_Off == ON ),  /* does ready matter */

                   status->Ready.Start       ||   /* ignore not ready events */
                   status->Ready.Pulse_Off   ||
                   status->Ready.VI_Flow_Off ||
                   status->Ready.SVent_Off   ||
                   status->Ready.Saver_On    ||
                   status->Ready.Purge_On,

                   (status->Ready.Start ? START_TIMEOUT : EVENT_TIMEOUT) / READY_EVAL_PERIOD,

                   status->Wkfile->Flow_Equib_Time / READY_EVAL_PERIOD    );


    return status->Ready.Flow.Reported_Ready == FALSE;

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CheckInletReadiness( pINLET_STATUS status )  /* NOTE !! this is called IMMEDIATELY after the inlet driver */
                                                  /*         The call is from PneuControl in p_ctrl .          */
/**end_proto**/

{


    U_INT8   pres_readiness;
    U_INT8   flow_readiness;
    U_INT8   inlet_purging;
    U_INT8   pres_pulse;

    if ( EpcInlet ( status ) )
    {
        pres_readiness = CheckInletPresReadiness( status );
        flow_readiness = CheckInletFlowReadiness( status );
    }
    else
    {
        pres_readiness = 0;   /* manual flow and pressure always ready */
        flow_readiness = 0;
    }


    if (( status->Wkfile->On_Off == ON ) || ( status->Config->Type == MANUAL_SS ))
    {
        inlet_purging = (( status->Ready.Controlling_Purge ) && ( status->Inlet_Purge ) && ( Run_State != RUN_ACTIVE ));
    }
    else
    {
        inlet_purging = FALSE;
    }

    if ( status->Wkfile->On_Off == ON )
    {
         if (( status->Wkfile->Injection_Mode == SPLIT_PULSED     ) ||
             ( status->Wkfile->Injection_Mode == SPLITLESS_PULSED ))
         {
              pres_pulse = ( Run_State != RUN_ACTIVE ) && ( !status->Pressure_Pulse );
         }
         else
         {
              pres_pulse = FALSE;
         }
    }
    else
    {
        pres_pulse = FALSE;
    }

    status->Ready.Setpt_Change = FALSE;
    status->Ready.Inlet_On     = FALSE;

    status->Ready.Start        = FALSE; /* flag is never reset, start is set by interrupt, not by a polled routine */

    if ( status->Position == FRNT_INLET )
    {
        if ( pres_readiness ) SetNewException  ( FRNT_INLET_PRESSURE, GetInletPresActual( status ), (INT32)GLP_F_INLET_PRES_NR );
        else                  ClearNewException( FRNT_INLET_PRESSURE );

        if ( flow_readiness ) SetNewException  ( FRNT_INLET_FLOW, GetInletFlowActual( status ), 0 );
        else                  ClearNewException( FRNT_INLET_FLOW );

        if ( inlet_purging && ( status->Wkfile->Injection_Mode != SOLVENT_VENT ))
        {
              SetNewException  ( FRNT_INLET_PURGING, 0, 0 );
        }
        else  ClearNewException( FRNT_INLET_PURGING );

        if (
            ( status->Wkfile->On_Off == ON    )                                                         &&
            (status->Wkfile->VI_Inj_Time != 0 )                                                         &&
            ( (Run_State == RUN_IDLE) || (( Run_State == PRE_RUN ) && ( status->VI_Flow_Mode == 0  )) ) &&
            (status->Inlet_Purge == FALSE  )
           )
        {  SetNewException  ( FRNT_INLET_VI_FLOW, 0, 0 ); }
        else
        {  ClearNewException( FRNT_INLET_VI_FLOW );       } ;

        if ( pres_pulse )  SetNewException  ( FRNT_INLET_PULSE, 0, 0 );
        else               ClearNewException( FRNT_INLET_PULSE );

        if (
            ( status->Wkfile->On_Off == ON ) && ( status->Wkfile->Injection_Mode == SOLVENT_VENT) &&
            ( Run_State != RUN_ACTIVE ) && ( !status->Solvent_Vent  )
           )
        {  SetNewException  ( FRNT_INLET_SOLV_VENT, 0, 0 ); }
        else
        {  ClearNewException( FRNT_INLET_SOLV_VENT );       } ;

    }
    else /* assume  status->Position == BACK_INLET */
    {
        if ( pres_readiness ) SetNewException  ( BACK_INLET_PRESSURE, GetInletPresActual( status ), (INT32)GLP_B_INLET_PRES_NR );
        else                  ClearNewException( BACK_INLET_PRESSURE );

        if ( flow_readiness ) SetNewException  ( BACK_INLET_FLOW, GetInletFlowActual( status ), 0 );
        else                  ClearNewException( BACK_INLET_FLOW );

        if ( inlet_purging && ( status->Wkfile->Injection_Mode != SOLVENT_VENT ))
        {
              SetNewException  ( BACK_INLET_PURGING, 0, 0 );
        }
        else  ClearNewException( BACK_INLET_PURGING );

        if (
            ( status->Wkfile->On_Off == ON    )                                                         &&
            (status->Wkfile->VI_Inj_Time != 0 )                                                         &&
            ( (Run_State == RUN_IDLE) || (( Run_State == PRE_RUN ) && ( status->VI_Flow_Mode == 0  )) ) &&
            (status->Inlet_Purge == FALSE  )
           )
        {  SetNewException  ( BACK_INLET_VI_FLOW, 0, 0 ); }
        else
        {  ClearNewException( BACK_INLET_VI_FLOW );       } ;

        if ( pres_pulse )  SetNewException  ( BACK_INLET_PULSE, 0, 0 );
        else               ClearNewException( BACK_INLET_PULSE );

        if (
            ( status->Wkfile->On_Off == ON ) && ( status->Wkfile->Injection_Mode == SOLVENT_VENT) &&
            ( Run_State != RUN_ACTIVE ) && ( !status->Solvent_Vent  )
           )
        {  SetNewException  ( BACK_INLET_SOLV_VENT, 0, 0 ); }
        else
        {  ClearNewException( BACK_INLET_SOLV_VENT );       } ;

    }

    if   ( ( Inst_Status.Pneu.Frnt_Inlet.Miser_Mode  && ( Active_Wkfile.Pneu.Frnt_Inlet.On_Off == ON ) )  ||
           ( Inst_Status.Pneu.Back_Inlet.Miser_Mode  && ( Active_Wkfile.Pneu.Back_Inlet.On_Off == ON ) )  )
    {
         if ( Run_State != RUN_ACTIVE ) SetNewException( MISER_MODE, 0, 0 );
         else                           ClearNewException( MISER_MODE );
         /* the above else clause must be here to prevent holding off readiness evaluation! */
    }
    else
    {
         ClearNewException( MISER_MODE );
    }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: Check inlet pre run conditions have happened.              */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void CheckInletReadinessAtStart( void )

/**end_proto**/

{

    Inst_Status.Pneu.Frnt_Inlet.Ready.Start = TRUE;
    Inst_Status.Pneu.Back_Inlet.Ready.Start = TRUE;
    Inst_Status.Pneu.Aux.Aux_3.Ready.Start  = TRUE;
    Inst_Status.Pneu.Aux.Aux_4.Ready.Start  = TRUE;
    Inst_Status.Pneu.Aux.Aux_5.Ready.Start  = TRUE;


    if ( Active_Wkfile.Pneu.Frnt_Inlet.On_Off == ON )
    {
          /* if pres pulse is enabled and we are not doing it, we are not ready */

         if ((( Active_Wkfile.Pneu.Frnt_Inlet.Injection_Mode == SPLIT_PULSED     ) ||
              ( Active_Wkfile.Pneu.Frnt_Inlet.Injection_Mode == SPLITLESS_PULSED ))    &&
             ( !Inst_Status.Pneu.Frnt_Inlet.Pressure_Pulse ) )
         {
             SetNewException  ( FRNT_INLET_PULSE, 0, 0 );
         }
    }


    if ( Active_Wkfile.Pneu.Back_Inlet.On_Off == ON )
    {
          /* if pres pulse is enabled and we are not doing it, we are not ready */

         if ((( Active_Wkfile.Pneu.Back_Inlet.Injection_Mode == SPLIT_PULSED     ) ||
              ( Active_Wkfile.Pneu.Back_Inlet.Injection_Mode == SPLITLESS_PULSED ))    &&
             ( !Inst_Status.Pneu.Back_Inlet.Pressure_Pulse ) )
         {
             SetNewException  ( BACK_INLET_PULSE, 0, 0 );
         }
    }



    if (( Active_Wkfile.Pneu.Frnt_Inlet.On_Off == ON ) || ( Inst_Config.Pneu.Frnt_Inlet.Type == MANUAL_SS ))
    {
          /* if splitless is enabled and we are not doing it, we are not ready */

         if (( Inst_Status.Pneu.Frnt_Inlet.Ready.Controlling_Purge ) && ( Inst_Status.Pneu.Frnt_Inlet.Inlet_Purge ) )
         {
              if ( Active_Wkfile.Pneu.Frnt_Inlet.Injection_Mode != SOLVENT_VENT )
              {
                   SetNewException  ( FRNT_INLET_PURGING, 0, 0 );
              }
         }
    }


    if (( Active_Wkfile.Pneu.Back_Inlet.On_Off == ON ) || ( Inst_Config.Pneu.Back_Inlet.Type == MANUAL_SS ))
    {
          /* if splitless is enabled and we are not doing it, we are not ready */

         if (( Inst_Status.Pneu.Back_Inlet.Ready.Controlling_Purge ) && ( Inst_Status.Pneu.Back_Inlet.Inlet_Purge ) )
         {
              if ( Active_Wkfile.Pneu.Back_Inlet.Injection_Mode != SOLVENT_VENT )
              {
                   SetNewException  ( BACK_INLET_PURGING, 0, 0 );
              }
         }

    }

    if ( Active_Wkfile.Pneu.Frnt_Inlet.On_Off == ON  )
    {
          /* IF volatiles AND inj_mode <> split AND vi_flow_mode == 0 THEN we are NOT ready */

         if ( ( Inst_Status.Pneu.Frnt_Inlet.Wkfile->VI_Inj_Time != 0  ) &&
              ( Active_Wkfile.Pneu.Frnt_Inlet.Injection_Mode != SPLIT ) &&
              ( Inst_Status.Pneu.Frnt_Inlet.VI_Flow_Mode == FALSE )       ) SetNewException( FRNT_INLET_VI_FLOW, 0, 0 );
    }

    if ( Active_Wkfile.Pneu.Back_Inlet.On_Off == ON  )
    {
          /* IF volatiles AND inj_mode <> split AND vi_flow_mode == 0 THEN we are NOT ready */

         if ( ( Inst_Status.Pneu.Back_Inlet.Wkfile->VI_Inj_Time != 0  ) &&
              ( Active_Wkfile.Pneu.Back_Inlet.Injection_Mode != SPLIT ) &&
              ( Inst_Status.Pneu.Back_Inlet.VI_Flow_Mode == FALSE )       ) SetNewException  ( BACK_INLET_VI_FLOW, 0, 0 );
    }


    if ( Active_Wkfile.Pneu.Frnt_Inlet.On_Off == ON  )
    {
         /* if Solvent Vent Mode &  we are not doing it, we are not ready */

         if ( ( Active_Wkfile.Pneu.Frnt_Inlet.Injection_Mode == SOLVENT_VENT     )    &&
              ( !Inst_Status.Pneu.Frnt_Inlet.Solvent_Vent   )                             )
         {
             SetNewException  ( FRNT_INLET_SOLV_VENT, 0, 0 );
         }
    }

    if ( Active_Wkfile.Pneu.Back_Inlet.On_Off == ON  )
    {
         /* if Solvent Vent Mode &  we are not doing it, we are not ready */

         if ( ( Active_Wkfile.Pneu.Back_Inlet.Injection_Mode == SOLVENT_VENT     )    &&
              ( !Inst_Status.Pneu.Back_Inlet.Solvent_Vent   )                             )
         {
             SetNewException  ( BACK_INLET_SOLV_VENT, 0, 0 );
         }
    }


    if   ( ( Inst_Status.Pneu.Frnt_Inlet.Miser_Mode  && ( Active_Wkfile.Pneu.Frnt_Inlet.On_Off == ON ) )  ||
           ( Inst_Status.Pneu.Back_Inlet.Miser_Mode  && ( Active_Wkfile.Pneu.Back_Inlet.On_Off == ON ) )  )
    {
         SetNewException( MISER_MODE, 0, 0 );
    }

}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void SlamInletPresSetpt( U_INT32 setpt, pINLET_STATUS status )

/**end_proto**/
{

     status->Inlet_Pressure_Setpt         = setpt;
     status->Intermediate_Pres            = setpt;
     status->Delayed_NTP_Inlet_Pres_Setpt = setpt;

     if ( Inst_Config.Pneu.Column_1.Source == status->Position )
     {
          OverideColumnSetpt ( setpt, &Inst_Status.Pneu.Column_1, status->Dcm2_Per_IU );
     }

     if ( Inst_Config.Pneu.Column_2.Source == status->Position )
     {
          OverideColumnSetpt ( setpt, &Inst_Status.Pneu.Column_2, status->Dcm2_Per_IU );
     }

     status->Ready.Setpt_Change = TRUE;

}

/**begin_proto**/

void SlamInletSetpt( pINLET_STATUS status )

/**end_proto**/
{
     status->Slam_Pres_Setpt = TRUE;
     status->Slam_Flow_Setpt = TRUE;

     status->Ready.Setpt_Change = TRUE;
}


/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void TwiddleInletSetptChangedFlag ( pINLET_STATUS status )

/**end_proto**/
{
     status->Ready.Setpt_Change = TRUE;
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

void Filter16Bits( U_INT16 *filter, U_INT16 value, U_INT16 rate )

/**end_proto**/
{

       if ( *filter < value )
       {
            if ( (value - *filter) > rate )
            {
                 *filter += (value - *filter) / rate;
            }
            else
            {
                 ++(*filter);
            }
       }
       else if ( *filter > value )
       {
            if ( (*filter - value) > rate )
            {
                 *filter -= (*filter - value) / rate;
            }
            else
            {
                 --(*filter);
            }
        }


}

/**begin_proto**/

void Filter32Bits( U_INT32 *filter, U_INT32 value, U_INT16 rate )

/**end_proto**/
{
       if ( *filter < value )
       {
            if ( (value - *filter) > rate )
            {
                 *filter += (value - *filter) / rate;
            }
            else
            {
                 ++(*filter);
            }
       }
       else if ( *filter > value )
       {
            if ( (*filter - value) > rate )
            {
                 *filter -= (*filter - value) / rate;
            }
            else
            {
                 --(*filter);
            }
        }
}

/**begin_proto**/

#pragma SECTION UNDO

/**end_proto**/
